title: LARAVEL ErrorException Undefined variable: emps (View: C:\xampp\htdocs\laravel\PFE\resources\views\admin\Provider-Unplanned.blade.php)
body: <p>i know there's alot of solutions for this question
  but i tried everything possible but i couldn't fix it
  here's my <strong>view called Provider-Unplanned.blade.php</strong>
  the error is :</p>
  <blockquote>
  <p>ErrorException
  Undefined variable: emps (View: C:\xampp\htdocs\laravel\PFE\resources\views\admin\Provider-Unplanned.blade.php)</p>
  </blockquote>
  <pre><code>&lt;table class=&quot;table table-striped table-dark&quot;&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th scope=&quot;col&quot;&gt; ID &lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;NAME &lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt; CODE &lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;SITE &lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;DATE &lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt; MATRICULE&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt; ARRIVAGE&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt; ENTRER&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt; SORTIE&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      @foreach($emps as $emp)
          &lt;tr&gt;
              &lt;td&gt;{{$emp-&gt;id}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;name}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;code}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;site}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;date}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;matricule}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;arrivage}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;entrer}}&lt;/td&gt;
              &lt;td&gt;{{$emp-&gt;sortie}}&lt;/td&gt;
          &lt;/tr&gt;
      @endforeach
      &lt;/tbody&gt;
  &lt;/table&gt;    
  </code></pre>
  <p>here's the <strong>controller code called ProviderController</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Admin;
  use DB;
  use Session;
  use App\Http\Controllers\Controller;
  use Illuminate\Http\Request;
  use App\Models\fournisseursjour;
  use App\unplannedprovider;
  
  
  class ProviderController extends Controller
  {
  public function ProviderUnplan(){
          return view('admin.Provider-Unplanned');
      }
   /* UNPLANNED PROVIDER */
  
      //DB Unplanned Provider
      public function unplanned()
      {
          $emps= unplannedprovider::all();
          return view('Provider-Unplanned')-&gt;with('emps',$emps);
      }
      //unplanned provider CRUD
  
      public function NewUnplanned(Request $request)
      {
         $this-&gt;validate($request,[
         'name'=&gt;'required',
         'code'=&gt;'required',
         'site'=&gt;'required',
         'date'=&gt;'required',
         'matricule'=&gt;'nullable',
         'arrivage'=&gt;'nullable',
         'entrer'=&gt;'nullable',
         'sortie'=&gt;'nullable',
       ]);
          $emps=new unplannedprovider;
          $emps-&gt;name=$request-&gt;input('name');
          $emps-&gt;code=$request-&gt;input('code');
          $emps-&gt;site=$request-&gt;input('site');
          $emps-&gt;date=$request-&gt;input('date');
          $emps-&gt;matricule=$request-&gt;input('matricule');
          $emps-&gt;arrivage=$request-&gt;input('arrivage');
          $emps-&gt;entrer=$request-&gt;input('entrer');
          $emps-&gt;sortie=$request-&gt;input('sortie');
  
          $emps-&gt;save();
          return redirect('Provider-Unplanned')-&gt;with('success','Data Saved');
      }
      
  
  }
  
  </code></pre>
  <p>finally <strong>web.php</strong></p>
  <pre><code>Route::get('/Provider-Unplanned','Admin\ProviderController@ProviderUnplan')-&gt;name('ProviderUnplan');
  
  Route::post('/Provider-Unplanned','Admin\ProviderController@NewUnplanned');
  </code></pre>