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
Post a Comment