title: Passing data from controller to view in Laravel
body: <p>I am new to Laravel and I have been trying to store all records of table 'student' to a variable and then pass that variable to a view so that I can display them.</p>
  <p>I have a controller - ProfileController and inside that a function:</p>
  <pre><code>public function showstudents() {
      $students = DB::table('student')-&gt;get();
      return View::make(&quot;user/regprofile&quot;)-&gt;with('students',$students);
  }
  </code></pre>
  <p>In my view, I have this code:</p>
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          //---HTML Head Part
      &lt;/head&gt;
      &lt;body&gt;
          Hi {{ Auth::user()-&gt;fullname }}
          @foreach ($students as $student)
              {{ $student-&gt;name }}
          @endforeach
          @stop
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I am receiving this error: <code>Undefined variable: students (View:regprofile.blade.php)</code></p>