title: Laravel Plucking 5.4 error variable undefined
body: <p><a href="https://i.stack.imgur.com/wItR6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wItR6.png" alt="enter image description here"></a>Error churchdetails is not defined:</p>
  
  <p>This is the pastorController</p>
  
  <pre><code>public function index()
  {
      $pastors = Pastor::all();
      $churchdetails = Church::all()-&gt;pluck('church_name','church_address');
      return view('addpastor')-&gt;withpastors($pastors)-&gt;withchurchdetails($churchdetails);
  }   
  
  public function create()
  {
     return view('addpastor');
  }
  
  public function store(Request $request)
  {
      //validation input
      $this-&gt;validate($request, [
          'pastor_name' =&gt; 'required|max:100',
      ]);
  
      $pastors = New Pastor;
      $pastors-&gt;pastor_name = $request-&gt;pastor_name;
  
      $pastors-&gt;save();
  
      return redirect()-&gt;back();
  }
  </code></pre>
  
  <p>This is the view</p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-8 col-md-offset-2"&gt;
              &lt;div class="panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;Add Church&lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      {!! Form::open(['route' =&gt; 'pastor.store']) !!}
                          {!!  Form::label('churches_id', 'Church Details:', null, array('class' =&gt; 'col-md-4 control-label')) !!}
  
                          {!!  Form::select('churches_id', $churchdetails, null, array('class'=&gt;'form-control', 'style' =&gt; 'height:34px', 'required' =&gt; ''))!!}
  
  
                      &lt;div class="form-group"&gt;
                          {!! Form::label('pastor_name', 'Pastor Name:') !!}
                          {!! Form::text('pastor_name', null, array('class' =&gt; 'form-control', 'required' =&gt; '', 'maxlength' =&gt; '100')) !!}
  
  
                      {!! Form::submit('Save Church', array('class' =&gt; 'btn btn-primary', 'style' =&gt; 'margin-top: 20px')) !!}
                      {!! Form::close() !!}
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  @endsection
  </code></pre>
  
  <p>This is the route</p>
  
  <pre><code>Route::resource('pastor', 'pastorController');
  Route::get('pastordetails', 'pastorController@index');
  </code></pre>
  
  <p>the churchdetails variable is not defined. What did I miss do to? Pls help</p>
  
  <p>and I have already created the relationship between church and pastor</p>
  
  <pre><code>public function churches()
  {
      return $this-&gt;belongsToMany('App\Church');
  }
  
  public function pastors()
  {
      return $this-&gt;belongsToMany('App\Pastor');
  }
  </code></pre>