hello everyone I have a problem here, can I sort the data based on the results of an Accessor, is it possible? or I do I have to move the data to the column database? this is my code in model
protected $appends = ['percentage'];
public function getPercentageAttribute()
{
$book = $this->books->halaman;
$read = $this->pageread;
$total = $read/$book*100;
return ceil($total);
}
I try with this code
$data = Read::with(['books.pengarang'])
->orderBy('percentage')
->get();
but I get error
Column not found: 1054 Unknown column percentage
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire