Support the ongoing development of Laravel.io →
posted 4 years ago
Last updated 1 year ago.
0

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

Last updated 4 years ago.
0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.