I have ExampleRepository
, who receives validated array, store it in db with some modification, and responses inserted/updated object. It uses function:
ExampleRepository:
public function store($validtedData)
{
//some code
return MyExampleModel::updateOrCreate(['id' => $id], [$modifiedData]);
}
Is it possible to understand, which action was used on object (update or insert)? I mean:
do not copy code below, such function not existence
$example = $this->exampleRepository->store($validatedData);
if ($example->justNewlyCreated())
//do something
else
//do something else
I don't need object_id nor other data, but only action used on object to store in db