Sending data to create user blade view
terrorfall opened this issue · comments
I've recently switched over to this package and am migrating the user registration over. I am attempting to send database data from the Registration controller to the view. My RegisterController has the following line:
return view('auth.register')->with('accounts', $accounts);
I can see that this logic is contained in
jeremykenedy\laravelusers\app\Http\Controllers\UsersManagementController@create
under this function:
public function create()
{
$roles = [];
if ($this->_rolesEnabled) {
$roles = config('laravelusers.roleModel')::all();
}
$data = [
'rolesEnabled' => $this->_rolesEnabled,
'roles' => $roles,
];
return view(config('laravelusers.createUserBlade'))->with($data);
}
Is there any way to migrate this logic into the CRUD routes that have setup by this package? Or extend the logic contained in the existing function?
You will need to write the login into your RegisterController itself. The UsersManagementController cannot be extended.
I logic you pasted above just gets the roles for use in a dropdown to select the roles.
The data from the model config('laravelusers.roleModel') is available to the entire app.
I've managed to get this working by overriding the UsersManagementController through composer:
"exclude-from-classmap": ["Jeremykenedy\\laravelusers\\App\\Http\\Controllers\\UsersManagementController.php"],
"files": ["app/Overrides/UsersManagementController.php"]
Awesome :)