Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel check if eloquent just created

$item = Item::firstOrCreate(['title' => 'Example Item']);

if ($item->wasRecentlyCreated === true) {
    // item wasn't found and have been created in the database
} else {
    // item was found and returned from the database
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #check #eloquent #created
ADD COMMENT
Topic
Name
5+4 =