First of all I would create the route in routes/api.php file to have the api namespace and other api (optional) authentications available (check official docs)
https://laravel.com/docs/5.8/routing
https://laravel.com/docs/5.8/api-authentication
To validate the data you can simply create form request validation on store() function
https://laravel.com/docs/5.8/validation#form-request-validation
To store the data in the DB you can create fillable attribute on User model with array of fields that can be populated by mass assignment and just do User::create($request->all())
https://laravel.com/docs/5.8/eloquent#mass-assignment
You don't have to create custom controller (but you can if you want of course)
Laravel is just... beautiful! :)
I would add some sort of security to your endpoint or anyone could post to create a new user
Make an api post route , example api/create-user
Point it to a controller method Example Public function create(Request $request){
$user = new User; $user->myfield_1 = “my data where “; $user->save();
}
Post your data from your external app to your new endpoint in laravel
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community