Why laravel eloquent model does not have an id after it is saved? -


i have account model. define & save following way:

$account = new account(); $account->email = $request->get('email'); $account->name  = $request->get('name'); $account->save();  dd($account->id) // null 

why account id not updated? use autoincremental id field. see record in database.

you should set primary key on model.

try insert on model:

protected $primarykey = "id"; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -