title: How to get data from database to view page in laravel?
body: <p>I am using Laravel 5.4 and I want to view my data in database from my view page (<code>listpetani.blade.php</code>).</p>
  
  <p>Here is the code of my project:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="table-responsive"&gt;
    &lt;table class="table table-striped table-hover table-condensed"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/th&gt;
          &lt;th&gt;&lt;strong&gt;Nama Petani&lt;/strong&gt;&lt;/th&gt;
          &lt;th&gt;&lt;strong&gt;Alamat&lt;/strong&gt;&lt;/th&gt;
          &lt;th&gt;&lt;strong&gt;No. Handphone&lt;/strong&gt;&lt;/th&gt;
          &lt;th&gt;&lt;strong&gt;Lokasi&lt;/strong&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>PHP:
  In my <code>listpetani.blade.php</code> I have an empty table and I want to show data from  <a href="https://i.stack.imgur.com/NJcU9.jpg" rel="noreferrer">database tbl_user</a>:</p>
  
  <pre><code>Route::get('listpetani', function () {
  
    $petani = DB::table('tbl_user')-&gt;pluck('id_user', 'username', 'alamat', 'no_telp', 'id_lokasi');
  
    return view('listpetani', ['petani' =&gt; $petani]);
  
  });
  </code></pre>
  
  <p>And the table in my page: <a href="https://i.stack.imgur.com/M8NEU.jpg" rel="noreferrer">view in browser</a></p>
  
  <p>I want to show all the data from database into my view in laravel 5.4. Can anybody help me?</p>