eloquent - How to check if a record is new in Laravel? -
i started using eloquent.
when used php active record, there nice function checked if record loaded database or new instance. there similar in eloquent use?
by new mean:
$article = new article;
whereas 1 database
$article = article::find(1);
all laravel models have ->exists
property.
more if model either loaded database, or has been saved database since being created exists
property true; otherwise false.
if wish know if model has been modified since being grabbed database, or not saved @ (aka if needs saving) can use ->isdirty()
function.
the laravel api useful place kind of information: http://laravel.com/api/4.2/illuminate/database/eloquent/model.html#method_isdirty , sheds far more light default documentation.
Comments
Post a Comment