mercredi 11 juillet 2018

Laravel 5 Add custom attribute in paginate()

I want to add custom attribute in model. i put:

// app/models/xxxModel.php
public function getTituloAttribute()
{
    return 'Cotizacion número: ' . $this->attributes['number'];
}

And then in Controller:

    $quotations         = AdminQuotations::orderBy('id', 'desc')->paginate()->toArray();

And i want to use xxxmodel->titulo in the view, but not appear this new attribute.

Thanks a lot, sory for my english.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire