mercredi 20 mars 2019

How to get id attribute in public function of model in Laravel?

In a laravel model I have:

public function generateUrl(){

    return $this->attributes['id'].' - '.$this->attributes['title'];
}

However I am getting "undefined index id". When I type dd($this) in attributes I see only title how can I add id?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire