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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -