Answer the question
In order to leave comments, you need to log in
Why doesn't firstOrCreate work in laravel?
I have my own table of cities and regions.
When registering, the user can select a city from the list or add a new one.
In the controller, I check if there is a variable with the new city and, if so, I call:
$city = City::firstOrCreate([
'name' => $request->new_city,
'region_id' => $request->region_id
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question