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
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SkgJ66
via IFTTT
Aucun commentaire:
Enregistrer un commentaire