lundi 30 septembre 2019

How To Sort Accessors In Laravel?

I have a Character Model Which have some Accessors which counts some items related to this model. I cannot use orderby because column does not exist in db and cannot use sortby because we use datatables (with angular). In postgres may be possible with lateral join but am using mysql. Is any other way to do this ? Accessors ex.

protected $appends = [
     "changes_count"
];

public function getChangesCountAttribute()
{
    return $this->changes()->where('type', 'Change')->count();
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2nNoOko
via IFTTT

Aucun commentaire:

Enregistrer un commentaire