Support the ongoing development of Laravel.io →
Database Eloquent

Howdy. I have nested resource controllers, like so:

http://example.org/v1/jobs/1/departments

My issue is trying to query all departments associated with job 1 using the ORM.

All relevant code, along with the error, is here:

https://gist.github.com/morganhein/9254678

How do I do this?

Last updated 3 years ago.
0

how about trying the following:

$positions = Auth::user()->jobs()->where('job_id', '=',$jobId)->first()->departments();
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

morganhein morganhein Joined 10 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.