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
bellow 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');
}
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 join `organizers` on `events`.`id` = `organizers`.`events_id` left join `tickets` on `events`.`id` = `tickets`.`events_id` group by `events`.`id` order by `events`.`id` desc limit 6)
pls how can I rectify this error is urgent, pls
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire