Has MySQL view 'histstat'.
In MySQL select * from histstat
works fine.
Laravel model is very simple:
class HistStat extends Model
{
use HasFactory;
protected $table = 'histstat';
protected $fillable = ['day', 'total', 'paid'];
}
Then I want to get first 14 records of hisstat:
$dynamic = HistStat::all()->slice(14);
... and execution ends with error SQLSTATE[42000]: Syntax error or access violation: 1055 (SQL: select * from 'histstat')
When I try to use table-based model ($dynamic = History::all()->slice(14);
) - everything works fine.
So, the problem in MySQL view + Laravel.
How to use view-based model in Laravel ?