firstorcreate is not working for new entry laravel -
i new laravel , using ardent creating models, have below base class model.
class mainmodel extends ardent { //with common methods }
and have sub model class such user
class user extends mainmodel { //with user table , other methods related user }
and have repository user ->user repository , calling firstorcreate method check(user entry) , create user. if user exists in database above method working fine ,its returning existing user object if user not exists in database not creating user not inserting entry table.is doing wrong here?
you need save user after calling firstorcreate()
:
$user->save();
you may want check if user doesn't exist before that:
if (!$user->id) $user->save();
Comments
Post a Comment