Laravel updateOrCreate Method

Laravel updateOrCreate  model where you will create model if it didn't exist but if so then update the same model.

    'country_from' => $request->input('country_from'),
    'country_to'   => $request->input('country_to'),
    'min_amount'             => $request->input('min_amount'),
    'max_amount'             => $request->input('max_amount'),

In above conditions first array is for checking and second is for update or insert so here is two scenarios.

1.It will check country_from and country_to exist with as per the name it will update min_amount and max_amount

2.If it didn't exist then create.

Leave a reply

your email address will not be published. required fields are marked *

Name *
Email *