title: laravel undefined variable: itinerary
body: <p>I can't seem to find the variable <strong>itinerary</strong> from my <strong>update</strong> function in my controller. What seems to be the problem for this?</p>
  
  <p>Error says: <strong>Undefined variable: itinerary (View: C:\xampp\htdocs\project_name\resources\views\Agent\edit.blade.php)</strong></p>
  
  <h3>AgentsController update function</h3>
  
  <pre><code>public function update(Request $request, $p_id){
      $this-&gt;validate($request, [
          'packageName' =&gt; 'required',
          'adultPrice' =&gt; 'required',
          'childPrice' =&gt; 'required',
          'infantPrice' =&gt; 'required',
          'excessPrice' =&gt; 'required',
          'type' =&gt; 'required',
          'inclusions' =&gt; 'required',
          'additionalInfo' =&gt; 'required',
          'reminders' =&gt; 'required',
          'photo' =&gt; 'required',
          'tags' =&gt; 'required',
          'noOfDays' =&gt; 'required',
          'day' =&gt; 'required',
          'time' =&gt; 'required',
          'destination' =&gt; 'required'
      ]);
  
      $packages = Packages::find($p_id);
      $packages-&gt;packageName = $request-&gt;input('packageName');
      $packages-&gt;adultPrice = $request-&gt;input('adultPrice');
      $packages-&gt;childPrice = $request-&gt;input('childPrice');
      $packages-&gt;infantPrice = $request-&gt;input('infantPrice');
      $packages-&gt;excessPrice = $request-&gt;input('excessPrice');
      $packages-&gt;type = $request-&gt;input('type');
      $packages-&gt;inclusions = $request-&gt;input('inclusions');
      $packages-&gt;additionalInfo = $request-&gt;input('additionalInfo');
      $packages-&gt;reminders = $request-&gt;input('reminders');
      $packages-&gt;photo = $request-&gt;input('photo');
      $packages-&gt;tags = $request-&gt;input('tags');
      $packages-&gt;save();
  
      $itinerary = Itinerary::find($p_id);
      if($itinerary-&gt;p_id == $packages-&gt;p_id){
      $itinerary-&gt;noOfDays = $request-&gt;input('noOfDays');
      $itinerary-&gt;day = $request-&gt;input('day');
      $itinerary-&gt;time = $request-&gt;input('time');
      $itinerary-&gt;destination = $request-&gt;input('destination');
      $itinerary-&gt;save();
  
      return redirect('Agent/Packages')-&gt;with('success', 'Updated');
      }
  }
  </code></pre>
  
  <h3>edit.blade.php where the error is located</h3>
  
  <pre><code>{{!!Form::open(array('class' =&gt; 'form-horizontal', 'method' =&gt; 'post', 'action' =&gt; array('AgentsController@update', $packages-&gt;p_id, $itinerary-&gt;p_id)))!!}}
  </code></pre>
  
  <h3>Itinerary.php Model</h3>
  
  <pre><code>&lt;?php
     namespace App;
  
     use Illuminate\Database\Eloquent\Model;
  
     class Itinerary extends Model{
        public $fillable = [
          'p_id',
          'noOfDays',
          'day',
          'time',
          'destination'
     ];
  
     protected $primaryKey = 'i_id';
     }
  ?&gt;
  </code></pre>
  
  <h3>Edit function</h3>
  
  <pre><code>public function edit($p_id){
     $packages = Packages::find($p_id);
     $itinerary = Itinerary::find($p_id);
  
     return View::make('\Agent\Edit', ['packages' =&gt; $packages, 'itineraries' =&gt; $itinerary]);
  }
  </code></pre>