Support the ongoing development of Laravel.io →
posted 7 years ago
Eloquent
Last updated 1 year ago.
0

Haven't tried it but something like this should work for you.

DB::table('obmains')
	->leftJoin('employeelogs', 'obmains.ob_code', '=', 'employeelogs.obcode')
	->leftJoin('users', function ($join) {
		$join->on('employeelogs.emp_id', '=', 'users.id')
			->whereNotIn('obmains.ob_code', DB::table('employeelogs')
				->whereIn('emp_id', DB::table('users')
					->where(function ($query) {
						$query->where('approver', 1)
							  ->orWhere('super_approver', 1);
					})
					->where('department', 4)
					->pluck('id')
				)
			->pluck('obcode')
		);
	})
	->select('obmains.*')
	->get();
0

wow thanks, its not working but its give me an idea thanks a lot =)

0

LOL WTF I SOLVE IT But the result of this query and the query above is put it in array, converting this query to eloquent is impossible, array and model is very different ANSWER TO MY QUESTION: IMPOSSIBLE TO CONVERT TO ELOQUENT


$obmain =  DB::table('obmains')
                ->leftJoin('employeelogs', 'obmains.ob_code', '=', 'employeelogs.obcode')
                ->leftJoin('users', 'employeelogs.emp_id','=','users.id')
                ->whereNotIn('obmains.ob_code',
                    (DB::table('employeelogs')
                        ->whereIn('emp_id',
                            (DB::table('users')
                                ->where('approver', 1)
                                ->orWhere(function ($query) {
                                    $query->where('super_approver', 1)
                                        ->where('department', Auth::user()->department);
                                })
                                ->select('id'))
                        )
                        ->select('obcode'))
               )
                ->get();




Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

xmatzx01 xmatzx01 Joined 28 Apr 2016

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.

© 2024 Laravel.io - All rights reserved.