vendredi 11 novembre 2016

Cant access an object property in laravel

I am getting results from a database in a controller and storing them as objects in an array

    $roleSentinel = Sentinel::findRoleByName($role);
    $permisssionsName = array_keys($roleSentinel['permissions']);
    $permissions = array();

    foreach ($permisssionsName as $permiso) {
        $permissions[] = DB::table('sec_permission')->where('name', '=',$permiso)->get();
    }

    return view('menu', ['role' => $role,'permisos' => $permisos]);

an object would be like

[{"permission_id":1,"name":"foo","object_id":1,"operation_id":1}]   

So then in the view I am trying to get the values and printing them

<b></b><br>
    @foreach ($permisos as $permiso)
         @foreach ($permiso->name as $name)
            
        @endforeach
    @endforeach

however I am getting Undefined property: Illuminate\Support\Collection::$name



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire