I am building an event website with laravel, my problem is that I want to query the event table in the DB and also organizers table and ticket table, the event table will provide the id which I will use to query the rest of the tables (tickets and organizers) which is linked with the events_id that is in both tickets and organizers
below is the code
$events = Events::orderBy('id', 'desc')
->leftJoin('organizers', 'events.id', '=', 'organizers.events_id')
->leftJoin('tickets', 'events.id', '=', 'tickets.events_id')
->paginate(env('EventPag'));
here is the code for the events model
public function organizers(){
return $this->hasMany('App\Organizers');
}
public function tickets(){
return $this->hasMany('App\Tickets');
}
here is the code for the organizers model
public function events(){
return $this->belongsTo('App\Events');
}
it gave me this error
Illuminate \ Database \ QueryException (42000)
SQLSTATE[42000]: Syntax error or access violation: 1055 'obj.events.name' isn't in GROUP BY (SQL: select events.* from
events
left joinorganizers
onevents
.id
=organizers
.events_id
left jointickets
onevents
.id
=tickets
.events_id
group byevents
.id
order byevents
.id
desc limit 6)
how can I rectify this error?