vendredi 26 janvier 2018

get field value from eloquent relationship

I have this relationship on eloquent

public function Manufacturer() { return $this->hasOne('App\Models\ManufacturerModel', 'id')->select('name'); }

And this returns correctly the manufacturer name:

{"id":1,"serialnumber":"123_1","buydate":"2018-01-26 00:00:00","offservice":null,"deleted":"0","manufacturer":{"name":"HP"}}

I want to retrieve the name not as JSON object but as a string

{"id":1,"serialnumber":"123_1","buydate":"2018-01-26 00:00:00","offservice":null,"deleted":"0","manufacturer":"HP"}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire