简体   繁体   中英

a complicated query by laravel eloquent orm

projects
id, name

projects_services(1 project_id <-> M service_id)
project_id, service_id

services
id, name

services_modules(M service_id <-> N module_id)
service_id, module_id

modules
id, name

modules_scripts(1 module_id<->1 script_id)
module_id, script_id

scripts
id, name

How can I query the follow infomation by scripts object?

script_id, script_name, module_name, service_name, project_name

$script->id;
$script->name;
$script->modules_script->module->name;

So on and so forth. Why you would need to do this baffles me me but if you really need to get everything through the script object and your relationships are set up correctly that should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM