I am working with Laravel 5.7 and do not go Auth command and make Login and Registration. but I have UserController and save data in users table as following.
protected function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'address' => $data['address'],
]);
$verifyUser = VerifyUser::create([
'user_id' => $user->id,
'token' => str_random(40)
]);
Mail::to($user->email)->send(new VerifyMail($user));
return $user;
}
now how can I make Route in web.php file to save above data.
Make create
method public and add fillable
property in your models and try to make route like this:
Route::post('register', 'RegisterController@create');
Hope this helps :)
add the following to routes: Route::post('url', 'ControllerName@MethodName');
which will be like below in your case:
Route::post('register', 'UserController@create');
You must change your method to public
instead of protected
.
In your web.php
routes file set the route as post
.
Example: Route::post('route_name', 'MethodController@method_name');
On your method create you can use Request $request
to get the data.
Example:
public function create(Request $request) {
$name = $request->data[0];
$email = $request->data[1];
$address = $request->data[2];
(rest of your code)
}