0

我猜我遇到了语法问题。我正在尝试对嵌套在另一个集合中的集合进行分组。这些集合一直在使用“with”检索,因为它们有关系。我的 grouBy 代码抛出一个错误,说我正在传递一个对象。

strtolower() 期望参数 1 是字符串,给定对象

这里有什么问题?

$clientAndAppointments = Client::where('status', 1)->orderby('first_name', 'asc')
    ->with(['appointments' => function ($query)  use ($weekStart, $weekEnd) {
         $query->whereBetween('starts_at', [$weekStart, $weekEnd])->groupBy(function($day) {
            return Carbon::parse($day->starts_at, 'Europe/London')->format('l');
        });            
    }, 'appointments.employees.user'])->with('careType')->get();
4

0 回答 0