php - Call to a member function lists() on null in laravel 5.3 -


in laravel 5.3, trying edit registered users in users page (admin/users) , assign roles , permissions them. used codes laravel 5.2 pdf book. anytime click on user edit it. brings below error

fatalthrowableerror in userscontroller.php line 26: call member function lists() on null.

public function edit($id) {     $user = user::whereid($id)->firstorfail();     $roles = role::all();     $selectedroles = $user->roles->lists('id')->toarray();     return view('backend.users.edit', compact('user', 'roles', 'selectedroles')); } 

the lists() function has been discontinued since laravel 5.3. should use pluck instead.

$selectedroles = $user->roles->pluck('id'); 

regarding error: must not having roles particular user, hence error.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -