mercredi 22 août 2018

Access json array property [duplicate]

This question already has an answer here:

I have a object called $permissions. It's a json object.

I need to get the id of roles. This is a sample of the data

{"data":{"roles":[{"id":1,"name":"administrator","guard_name":"web","created_at":"2018-08-17 17:16:38","updated_at":"2018-08-17 17:16:38","permissions":[1,4,5]]}}

I'm passing permission back via my url, and I need to access it as my id.

Ideally, I can store the role id, in a id variable and use that to find the correct role.

public function update(Request $request, $permissions)
{

   $role = Role::find($id);

   $role->syncPermissions($request->permissions);
}

How do I access this property?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire