title: How to pass parameters between controller methods
body: <p>I am having problems getting the value of custom create method. What I want is to get the variable $student_id and place it on my findOrFail() in the index method as shown below:</p>
  
  <p>ReservationController.php</p>
  
  <pre><code>public function index()
  {
  
      $student = Student::with(['sectionSubjects','sectionSubjects.section', 
                  'sectionSubjects.subject'])-&gt;findOrFail(1); //$student_id
  
      return $student-&gt;sectionSubjects;    
  
  }
  
  public function create($id)
  {
      $student_id = $id;
  
      $subjects = Subject::with('sections')-&gt;get();
  
      return view('reservation.form',compact('subjects','student_id'));
  }
  </code></pre>
  
  <p>Here's my route:</p>
  
  <pre><code>Route::resource('student', 'StudentController');
  Route::resource('reservation', 'ReservationController', ['except' =&gt; ['create','show'] ]);
  
  Route::get('reservation/{id}/create', 
      ['as' =&gt; 'reservation.create', 'uses' =&gt; 'ReservationController@create'
  ]);
  </code></pre>
  
  <p>I have this form.blade.php that when a user click on a student it will be redirected to the custom create method in the ReservationController as seen below:</p>
  
  <pre><code>&lt;div class="list-group "&gt;
  @inject('student', 'App\Http\Controllers\StudentController')
      @foreach($student-&gt;index() as $s)
          &lt;div class="list-group-item"&gt;
              &lt;h4 class="list-group-item-heading"&gt;
                  {{ $s-&gt;first_name }} {{ $s-&gt;middle_name }} {{ $s-&gt;last_name }}&lt;/i&gt;
              &lt;/h4&gt;
              &lt;h5&gt;
                 ID No.: {{ $s-&gt;id_no }}&lt;/i&gt;
              &lt;/h5&gt;
  
             &lt;a href="{{ route('student.edit', $s-&gt;id) }}" class="btn btn-xs btn-primary"&gt;Edit Info&lt;/a&gt;
  
             &lt;a href="{{ route('reservation.create', $s-&gt;id ) }}" 
                class="btn btn-xs btn-danger"&gt;
                Enroll
              &lt;/a&gt; 
  
          &lt;/div&gt;
      @endforeach
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Now in the index method in the ReservationController, I want to fetch only values that are related to that $student_id. However, I cannot figure out to achieve this. Can anyone suggest ways to solve this?</p>