I want to count a field name 'leave_policy' depending on the name of 'leave_policy' and I am using joins to do it and still want to use joins. My database is like this https://imgur.com/a/gR3Dw
$join = DB::table('leaves_policy')
->join('leaves_policies', 'leaves_policy.leave_policy', '=', 'leaves_policies.title')
->join('leaves_requests', 'leaves_policy.requested_by' , '=', 'leaves_requests.requested_by')
->select('leaves_policy.*', 'leaves_policies.title', 'leaves_policies.total_no_of_leaves_allowed_per_year',
'leaves_policies.no_of_months_leaves_valid', 'leaves_policies.max_leaves_per_month', 'leaves_policies.max_con_leaves_per_month',
'leaves_requests.leave_status', DB::raw('count(leaves_policy.leave_policy) where leaves_policy.leave_policy'))
->groupBy('leaves_policy.id')
->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire