w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Retrieve all child records based on parent with Laravel 4 and mySQL

I believe I found an answer:

$users = User::select('users.id as user_id', 'users.email as email') ->distinct() ->join('user_block', 'users.id', '=', 'user_block.user_id') ->join('blocks', 'user_block.block_id', '=', 'blocks.id') ->where('blocks.project_id','=',$project_id) ->get(); where I pass the project_id to limit the records returned.

I'm still able to access the model in the blade template to call a function which checks which users have uploaded all the required documents for each block.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.