samedi 25 juin 2022

ErrorException Undefined variable: users (View: resources\views\admin\dashboard.blade.php)

hi I wants to show users list into my dashboard pannel but it shows me this problem :

ErrorException Undefined variable: users (View: resources\views\admin\dashboard.blade.php)

Controller File :

 public function index()
{
    $listuser = User::all();
    return view('admin.dashboard',['users' => $listuser]);
    //return view('admin.dashboard')->with('users', $listuser);
}

blade file :

 <div id="utilisateurs">
                            <table width="100%" cellspacing="0" border="1">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Nom et Prenom</th>
                                            <th>Email</th>
                                            <th>tele</th>
                                            <th>adresse</th>
                                            <th>date de creation</th>
                                            <th>Statut de compte</th>
                                        </tr>
                                    </thead><br>
                                    <tbody>
                                        
                                        @foreach($users as $user)
                                            @if($user->role_as=='0')
                                        <tr>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td>Null</td>
                                        </tr>
                                            @endif
                                        @endforeach
                                    </tbody>
                            </table>
                        </div>

Routes :

  Route::middleware(['auth','isAdmin'])->group(function() {
Route::get('/dashboard','Admin\FrontendController@index');


/*users routes*/
Route::get('/dashboard', 'UserController@index');


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire