Vishaal
163
3
Laravel

Join eloquent display Laravel

Posted 2 months ago by Vishaal

Hello,

I'm trying to get the result of all jobs like:

JobID date starttime endtime room location

Print who is assign to this job

first_name last_name

I have join the tables to get all result but i'm getting the result like:

[{"id":21,"date":"2019-05-09","starttijd":"15:00:00","eindtijd":"17:00:00","kamernummer":"06B12","locatie":"1","first_name":"test","last_name":"test"},
{"id":21,"date":"2019-05-09","starttijd":"15:00:00","eindtijd":"17:00:00","kamernummer":"06B12","locatie":"1","first_name":"test2","last_name":"test2"},
{"id":21,"date":"2019-05-09","starttijd":"15:00:00","eindtijd":"17:00:00","kamernummer":"06B12","locatie":"1","first_name":"test2","last_name":"test2"}]

How i can display this in the format what i required in view.

query:


        $jobslist = Job::Join('ingedeeldjobs','ingedeeldjobs.job_id', '=', 'jobs.id')
                        ->Join('users', 'users.id', '=', 'ingedeeldjobs.user_id')
                        ->where('jobs.date', $datum)
                        ->where('jobs.cronstatus', 'scheduled')
                        ->where('locatie', $locatie)
                        ->get(['jobs.id','jobs.date','jobs.starttijd','jobs.eindtijd','jobs.kamernummer','jobs.locatie', 'users.first_name', 'users.last_name']);

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