title: Edit and updating fails for joining table in Laravel 7
body: <p>I have two tables (City and Area). The city has many areas. So I have successfully added and deleted the data. But I am facing multiple errors while editing and updating. I have just started learning Laravel. I used a resource controller but encountered a problem with declaring routes, so I tried the name route also.</p>
  
  <p>This error I have encountered: <code>Trying to get property 'id' of non-object</code>
  and indicates the form's route ID. which is <code>$editArea-&gt;id</code>. Here is my code.</p>
  
  <p>web.php route: </p>
  
  <pre><code>Route::resource('area','Admin\AreaController');
   Route::get('area/edit/{id}','Admin\AreaController@edit')-&gt;name('area.edit');
   Route::post('area/update/{id}','Admin\AreaController@update')-&gt;name('area.update');
  </code></pre>
  
  <p>edit button: <code>&lt;a href="{{route('area.edit', $row-&gt;id)}}"&gt;Edit&lt;/a&gt;</code></p>
  
  <p>AreaController: </p>
  
  <pre><code>public function edit(Area $area, $id)
  
      {
  
          $editArea= Area::find($id);
          $cityno= City::orderBy('city_name', 'asc')-&gt;get();
          return view('admin.editArea', compact('editArea','cityno'));
      }
  public function update(Request $request, Area $area, $id)
      {
  
          $editArea=Area::find($id);
          $editArea-&gt;city_id=$request-&gt;city_id;
          $editArea-&gt;area_name=$request-&gt;area_name;
          $editArea-&gt;save();
  
      }
  </code></pre>
  
  <p>edit form: </p>
  
  <pre><code>&lt;form method="POST" action="{{route('area.update', $editArea-&gt;id)}}"&gt;
                  @csrf
                  @method('put')
                      &lt;select name="city_id"&gt;
                          @foreach($cityno as $row)
                              &lt;option value="{{$row-&gt;id}}" &gt;{{ucwords($row-&gt;city_name)}}&lt;/option&gt;
                              @endforeach
                          &lt;/select&gt;
                  &lt;input type="text" name="area_name" value="{{$editArea-&gt;area_name}}"&gt;
                      &lt;button type="submit"&gt;Update Area&lt;/button&gt;
                 &lt;/form&gt;
  </code></pre>
  
  <p>Area model: </p>
  
  <pre><code>public function city(){
         return $this-&gt;belongsTo(City::class,'city_id');}
  </code></pre>
  
  <p>city model:</p>
  
  <pre><code>  public function area(){
          return $this-&gt;hasMany(Area::class); }
  </code></pre>
  
  <p>As I'm a new learner, I'm stuck in these files to find my wrong code. </p>