title: What's the cause Undefined property: stdClass?
body: <p>I don't know what this error cause. I didn't change anything in my codes. But when I go to my search view. It always returns me the undefined property error. This error cause when I tried to <strong>foreach</strong> all my columns in my table data. I already solve this error not once. Because it cannot find the <code>$id</code> of selected options. But this time I can't fix it. </p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Undefined property: stdClass::$id (View: C:\Users\JohnFrancis\LaravelFrancis\resources\views\document\show.blade.php)</p>
  </blockquote>
  
  <p><strong>View</strong></p>
  
  <p>show.blade.php - This view will list all the values in my tables.</p>
  
  <pre><code>@section ('content')
  
  &lt;div class = "col-md-12"&gt;
  
      &lt;table class = "table"&gt;
  
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Title&lt;/th&gt;
                  &lt;th&gt;Content&lt;/th&gt;
                  &lt;th&gt;Category&lt;/th&gt;
                  &lt;th&gt;Sender&lt;/th&gt;
                  &lt;th&gt;Date Received&lt;/th&gt;
                  &lt;th&gt;Action&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
  
          &lt;tbody&gt;
              @foreach ($documentLists as $list)
                  &lt;tr class = "info"&gt;
                      &lt;td&gt;{{ $list-&gt;title }}&lt;/td&gt;
                      &lt;td&gt;{{ strip_tags(substr($list-&gt;content, 0, 50)) }} {{  strlen($list-&gt;content) &gt; 50 ? "..." : '' }}&lt;/td&gt;
                      &lt;td&gt;{{ $list-&gt;category_type }}&lt;/td&gt;
                      &lt;td&gt;{{ $list-&gt;username }}&lt;/td&gt;
                      &lt;td&gt;{{ date('M j, Y', strtotime($list-&gt;dateReceived)) }}&lt;/td&gt;
                      &lt;td&gt;
                          &lt;a href = "{{ route ('document.read', $list-&gt;id) }}"&gt;&lt;button type = "submit" class = "btn btn-info"&gt;Read&lt;/button&gt;&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              @endforeach
          &lt;/tbody&gt;
  
      &lt;/table&gt;
  
  &lt;/div&gt;
  
  @endsection
  </code></pre>
  
  <p>read.blade.php - This where it will redirect to the current view that selected.</p>
  
  <pre><code>&lt;!--DOCUMENT CONTROLLER--&gt;
  &lt;div class = "col-md-6"&gt;
  
  &lt;form class = "vertical"&gt;
  
      &lt;div class = "form-group"&gt;
  
          &lt;textarea id = "content"&gt;{{ $documentLists-&gt;content }}&lt;/textarea&gt;
  
      &lt;/div&gt;
  
      &lt;div class = "form-group"&gt;
  
          &lt;button type = "submit" class = "btn btn-success"&gt;Approve&lt;/button&gt;
  
      &lt;/div&gt;
  
  &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>//SHOW
  public function showDocuments()
  {
  
      $documentLists = DB::table('document_user')-&gt;select('documents.title', 'documents.content', 'categories.category_type', 'users.username', 'document_user.dateReceived')
          //Table name     //PK                  //FK
          -&gt;join('users', 'users.id', '=', 'document_user.sender_id')
          -&gt;join('documents', 'documents.id', '=', 'document_user.document_id')
          -&gt;join('categories', 'categories.id', '=', 'documents.category_id')
          -&gt;where('sender_id', '!=', Auth::id())
          -&gt;where('user_id', '!=', Auth::id())-&gt;get();
  
      //VIEW
      return view ('document.show')-&gt;with('documentLists', $documentLists);
  }
  
  //READ
  public function readDocuments($id)
  {
      //Find the document in the database and save as var.
      $documentLists = Document::find($id);
  
      return view ('document.read')-&gt;with('documentLists', $documentLists);
  }
  </code></pre>
  
  <p><strong>routes</strong></p>
  
  <pre><code>Route::get('/show',
  [
      'uses' =&gt; '\App\Http\Controllers\DocumentController@showDocuments',
      'as' =&gt; 'document.show',
      'middleware' =&gt; 'auth',
  ]);
  
  Route::get('/receive/documents/{id}',
  [
      'uses' =&gt; '\App\Http\Controllers\DocumentController@readDocuments',
      'as' =&gt; 'document.read',
      'middleware' =&gt; 'auth',
  ]);
  </code></pre>