如何在laravel 9网站上运行带有型号名称和过滤器设置为字符串的请求:
runRequest(model: \App\Models\Vote::class, filter:"status = 'A'");
public function runRequest(string $model, string $filter)
{
$data = $model::whereRaw($filter)
->orderBy('id', 'asc')
->get();
}
但出现错误:
Class name must be a valid object or a string
如何让它发挥作用?
"laravel/framework": "^9.19",
先谢了!
1条答案
按热度按时间wgeznvg71#
用这个