mercredi 3 octobre 2018

Laravel 5.4 formatting result set

Can someone help me convert this query so that my result set is in different format?

$sessions = new Session();
$results =  $sessions->where('session_status', $status)->where('application_period_id', (int) ApplicationPeriod::all()->last()->id)->get()->pluck('speaker_id');

$speakers = Speaker::whereIn('id', $results)
                ->with('session.audiancesession.audiances')
                ->with('session.subjectsession.subjects')
                ->with(['session' => 
                       function ($query) use($status) {
                           $query->where('session_status', '=', $status);
                }])->orderBy('last_name')->get();

This is requested via Ajax(axios)... Now this is how result is formatted:

Obj->data(array of objects)->[0]->name
                                ->address
                                ->session(array of objects)
                                       ->[0]->time
                                            ->fee

My issue is that my session parameter is array and there can only ever be (1) so I don't need to to be an array and I would like to have object (json) instead.

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire