i know there's alot of solutions for this question but i tried everything possible but i couldn't fix it here's my view called Provider-Unplanned.blade.php the error is :
ErrorException Undefined variable: emps (View: C:\xampp\htdocs\laravel\PFE\resources\views\admin\Provider-Unplanned.blade.php)
<table class="table table-striped table-dark">
<thead>
<tr>
<th scope="col"> ID </th>
<th scope="col">NAME </th>
<th scope="col"> CODE </th>
<th scope="col">SITE </th>
<th scope="col">DATE </th>
<th scope="col"> MATRICULE</th>
<th scope="col"> ARRIVAGE</th>
<th scope="col"> ENTRER</th>
<th scope="col"> SORTIE</th>
</tr>
</thead>
<tbody>
@foreach($emps as $emp)
<tr>
<td>{{$emp->id}}</td>
<td>{{$emp->name}}</td>
<td>{{$emp->code}}</td>
<td>{{$emp->site}}</td>
<td>{{$emp->date}}</td>
<td>{{$emp->matricule}}</td>
<td>{{$emp->arrivage}}</td>
<td>{{$emp->entrer}}</td>
<td>{{$emp->sortie}}</td>
</tr>
@endforeach
</tbody>
</table>
here's the controller code called ProviderController
<?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')->with('emps',$emps);
}
//unplanned provider CRUD
public function NewUnplanned(Request $request)
{
$this->validate($request,[
'name'=>'required',
'code'=>'required',
'site'=>'required',
'date'=>'required',
'matricule'=>'nullable',
'arrivage'=>'nullable',
'entrer'=>'nullable',
'sortie'=>'nullable',
]);
$emps=new unplannedprovider;
$emps->name=$request->input('name');
$emps->code=$request->input('code');
$emps->site=$request->input('site');
$emps->date=$request->input('date');
$emps->matricule=$request->input('matricule');
$emps->arrivage=$request->input('arrivage');
$emps->entrer=$request->input('entrer');
$emps->sortie=$request->input('sortie');
$emps->save();
return redirect('Provider-Unplanned')->with('success','Data Saved');
}
}
finally web.php
Route::get('/Provider-Unplanned','Admin\ProviderController@ProviderUnplan')->name('ProviderUnplan');
Route::post('/Provider-Unplanned','Admin\ProviderController@NewUnplanned');