title: “Undefined variable: a ” in laravel 5.2 view
body: <p>Help me please im a newbie using laravel, when I am using Relations,I am getting an error as bellow..     </p>
  
  <blockquote>
    <p>ErrorException in 5ef4934eeff3d728094534ae49b02bc13ec04ae1.php line 122:
    Undefined variable: a (View: E:\xampp\htdocs\beasiswa\resources\views\beasiswa\daftar_beasiswa.blade.php)</p>
  </blockquote>
  
  <p><strong>Controller</strong> is in BeasiswaController.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Beasiswa;
  use App\Databeasiswa;
  use Illuminate\Support\Facades\Input;
  
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  use App\Http\Controllers\BeasiswaController;
  
  class BeasiswaController extends Controller
  {
      public function index(){
       $data = Beasiswa::all();
          return view('beasiswa.daftar_beasiswa')-&gt;with('data', $data);
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>Route</strong> is defined like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Route::resource('/beasiswa', 'BeasiswaController');
  Route::get('beasiswa', 'BeasiswaController@index');</code></pre>
  </div>
  </div>
  </p>
  
  <p>And this is my <strong>Models</strong> Beasiswa.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Beasiswa extends Model
  {
      protected $fillable = [
         'nama_bea', 
         'syarat', 
         'waktu_pendaftaran',
         'status'
         ];
  
   public function callDatabeasiswa(){
    return $this-&gt;hasMany('App\Databeasiswa');
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>And this is my <strong>View</strong> on daftar_beasiswa.blade.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table class="table table-striped"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
        &lt;th style="width: 20px"&gt;No&lt;/th&gt;
        &lt;th&gt;Nama Beasiswa&lt;/th&gt; 
        &lt;th&gt;Periode Pendaftaran&lt;/th&gt;                
        &lt;th style="width: 45px"&gt;Edit&lt;/th&gt;
        &lt;th style="width: 45px"&gt;Detail&lt;/th&gt;
        &lt;th style="width: 45px"&gt;Hapus&lt;/th&gt;
        &lt;th style="width: 45px"&gt;Broadcast&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  
  &lt;tbody&gt;
   @foreach($data as $a)
   &lt;tr&gt;
    &lt;td&gt;{{ $a-&gt;id }}&lt;/td&gt;
    &lt;td&gt;{{ $a-&gt;nama_bea }}&lt;/td&gt;
    &lt;td&gt;{{ $a-&gt;waktu_pendaftaran }}&lt;/td&gt;
    &lt;td&gt;
     &lt;a href="{{ url('beasiswa/'.$a-&gt;id.'/edit') }}" class="btn btn-info btn-sm"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
     &lt;a href="{{ url('beasiswa/'.$a-&gt;id) }}" class="btn btn-warning btn-sm"&gt;&lt;i class="glyphicon glyphicon-eye-open"&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
     &lt;form action="{{ url('beasiswa/'.$a-&gt;id) }}" method="post"&gt;
     {{ csrf_field() }}
     &lt;input type="hidden" name="_method" value="DELETE"&gt;&lt;button type="submit" class="btn btn-danger btn-sm"&gt;&lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt;&lt;/button&gt;
     &lt;/form&gt;
    &lt;/td&gt;
    &lt;!-- POST --&gt;
    &lt;td&gt;
      &lt;!-- BUTTON SEND VIA TELEGRAM --&gt;
     {{ csrf_field() }}
     &lt;button data-toggle="modal" data-target="#modal-sendtelegram" type="button" class="btn btn-primary btn-sm"&gt;&lt;i class="glyphicon glyphicon-send"&gt;&lt;/i&gt;&lt;/button&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
   @endforeach
  &lt;/tbody&gt;
  
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>