FutureWeb
1 year ago

GroupBy works on local testing server but not on production?

Posted 1 year ago by FutureWeb

Hi LaraPeeps,

I have this relationship in my User Model:

public function invoices()
{
    return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoices.id','orders.user_id']);
}

this works as does the below (on my local machine)

    public function invoices()
{
    return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoice_id','user_id']);
}

but on my production server I get this error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'shopsite_db.invoices.title' isn't in GROUP BY (SQL: select `invoices`.*, `orders`.`user_id` from `invoices` inner join `orders` on `orders`.`invoice_id` = `invoices`.`id` where `orders`.`user_id` = 1 group by `invoices`.`id`, `orders`.`user_id`)

Please sign in or create an account to participate in this conversation.