I'm trying to make my Laravel UserController
as lean as possible without using any additional packages, like Ardent (I find it unnecessary; overkill.)
This is my postRegister()
function, the function that is routed to when the user clicks "submit" on the registration form.
public function postRegister() {
$validator = new Services\Validators\RUser;
if ($validator->passes()) {
User::create(Input::all());
return Redirect::to('login');
}
return Redirect::to('register')->withInput()->withErrors($validator->getErrors());
}
I sent all the input off to be validated in another class, then I just call the class statically with User::create()
. I'm wondering if this is safe or not. I'm having everything but the id
and password_confirmation
mass-assigned, and the password is hashed in a mutator function.
If this isn't a safe way to handle user creation, how else should I do it? Should I instead create an instance of the object and manually assign values? Thanks in advance.