我想通过查询作为参数:
$query = Users::where('name', 'John');
useQuery($query);
function useQuery($query) {
$results = $query->get();
....
}
我得到:
不允许对“关闭”进行序列化
是否可以通过某种方式将查询传递给这样的函数?
编辑:我意识到问题出在另一个地方:
class ExportCsv implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $filename;
private $query;
public function __construct($query, $filename)
{
$this->query = User::where('name', 'John'); // = $query
}
...
}
此处发生序列化错误:$this->query = User::where('name', 'John');