mardi 19 mars 2019

use condition in laravel controller

i want to fetch data only when the auth is an admin. The User controller:

public function index()
{
    if (auth::user()->type == 'admin') {
        # code...

   return User::where('type','!=','admin')->latest()->paginate(100);

}}

i got an error: Trying to get property 'type' of non-object.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire