jeremykenedy / laravel-users

A Users Management Package that includes all necessary routes, views, models, and controllers for a user management dashboard and associated pages for managing Laravels built in user scaffolding. Built for Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6.0, 7.0 and 8.0.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 :)