title: Laravel - ErrorException Undefined index: firstname
body: <p>Sup y'all,I am new to Laravel and I'm trying to make crud operations example with adding,modifying,deleting authors and books.So my authors crud works alright, but when I try to create a book by getting the created author I get this error:  </p>
  
  <pre><code>ErrorException (E_NOTICE)
  "Undefined index: firstname"
  </code></pre>
  
  <p>So heres my code:
  my Authors.php</p>
  
  <pre><code>class Authors extends Model
  {
      protected $table ='authors';
      protected $fillable = ['firstname','lastname'];
  
      public function book()
      {
          return $this-&gt;hasMany('Books','author');
      }
  }
  </code></pre>
  
  <p>my Books.php:</p>
  
  <pre><code>class Books extends Model
  {
      protected $table = 'books';
      protected $fillable = ['title'];
      public function author()
      {
          return $this-&gt;belongsTo('App\Authors');
      }
  }
  </code></pre>
  
  <p>my BooksController.php(where it actually gets the exception):</p>
  
  <pre><code> public function create()
      {
          return view('books.index');
      }
  
      public function store(Request $request)
      {
  
          $inputs = $request-&gt;all();
  
          $book = new Books();
          $book-&gt;title = $inputs['title'];
  
          $book-&gt;author()-&gt;attach($inputs['firstname']);
          $book-&gt;author()-&gt;attach($inputs['lastname']);
  
          $book-&gt;save();
          return redirect('/books');
      }
  </code></pre>
  
  <p>my index.php:</p>
  
  <pre><code>@section('content')
  
      &lt;div class="container"&gt;
          &lt;form method="post" action="{{url('books')}}"&gt;
              &lt;div class="form-group row"&gt;
                  {{csrf_field()}}
                  &lt;label for="lgFormGroupInput" class="col-sm-2 col-form-label col-form-label-lg"&gt;Title&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                      &lt;input type="text" class="form-control form-control-lg" id="lgFormGroupInput" placeholder="title" name="title"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group row"&gt;
                  {{csrf_field()}}
                  &lt;label for="lgFormGroupInput" class="col-sm-2 col-form-label col-form-label-lg"&gt;Author&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                      &lt;select id="author" name="author"&gt;
                          &lt;option value="Z"&gt;Select an author&lt;/option&gt;
                          @foreach ($authors as $author)
                          &lt;option value="{{$author['id']}}"&gt;{{$author['firstname']}} {{$author['lastname']}}&lt;/option&gt;
                          @endforeach
                      &lt;/select&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
                      &lt;input type="submit" value="Create" /&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
      &lt;div class="container"&gt;
          &lt;table class="table table-striped"&gt;
              &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;ID&lt;/th&gt;
                  &lt;th&gt;Title&lt;/th&gt;
                  &lt;th&gt;Author&lt;/th&gt;
              &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
              @foreach($books as $book)
                  &lt;tr&gt;
                      &lt;td&gt;{{$book['id']}}&lt;/td&gt;
                      &lt;td&gt;{{$book-&gt;$author['firstname']}} {{$book-&gt;$author['lastname']}}&lt;/td&gt;
                      &lt;td&gt;&lt;a href="{{action('BooksController@edit', $book['id'])}}" class="btn btn-warning"&gt;Edit&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;
                          &lt;form action="{{action('BooksController@destroy', $book['id'])}}" method="post"&gt;
                              {{csrf_field()}}
                              &lt;input name="_method" type="hidden" value="DELETE"&gt;
                              &lt;button class="btn btn-danger" type="submit"&gt;Delete&lt;/button&gt;
                          &lt;/form&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              @endforeach
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
   @endsection
  </code></pre>
  
  <p>So, I have no idea why do I get this exception in the store of my controller...Thanks in advance!</p>