1 month ago

Check whether record has created or not

Posted 1 month ago by shantodev

I've a simple post form. Records are saved to database with updateOrCreate function.

I've following records to be stored,

user_id product_id review rating

After submitting form, user_id and product_id are used to check if record exist or not. If exist, record will be updated otherwise new record created with the function.

public function updateOrCreate($input)
    return $this->model->updateOrCreate(['product_id'=> $input['product_id'],'user_id'=>$input['user_id']],['rating'=>$input['rating'],'review'=>$input['review']]);

Is there any built in method to find new record created or existing record updated ?

Any kind of suggestion is appreciated.

Please sign in or create an account to participate in this conversation.