PHP
or where laravel
MyMode::where(['user_id' => 1])
->orWhere(['assigned_to' => 1])
->get();
laravel where
$users = DB::table('users')
->whereDate('created_at', '2016-12-31')
->get();
where in laravel
$users = Users::whereIn('id', array(1, 2, 3))->get()
where with and and or in a laravel
$users = DB::table('user')->select('id', 'name', 'email','api_token','created_at')
->where('email' , $email)
->where('name' , $name)
->get();
laravel with and where
$projects = Project::whereHas('projectOffers', function ($offer) {
$offer->where('teacher_id', "Ahmed");
$offer->where('status_id', "Accepted");
})->where('status_id', "inprogress")->get();
laravel where in
$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get()
where clause in laravel
$users = DB::table('user')->select('id', 'name', 'email','api_token','created_at')->where('email' , $email)->get();
return response()->json($users);
laravel where and where
Table::where('Column', Value)->where('NewColumn', Value)->get();
laravel where
$users = DB::table('users')
->whereMonth('created_at', '12')
->get();
larave with using where
Event::with(["participants" => function($q){
$q->where('participants.IdUser', '=', 1);
}])
larave with using where
Event::with(["participants" => function($q){
$q->where('participants.IdUser', '=', 1);
}])
how to use or where in laravel
if (!empty($search)){
$member = $member->where(function($q)use($search){$q->where('name', 'LIKE', '%' . $search . '%')->orWhere('contact', 'LIKE', '%' . $search . '%')->orWhere('contact02', 'LIKE', '%' . $search . '%')->orWhere('email', 'LIKE', '%' . $search . '%')->orWhere('blood_group', 'LIKE', '%' . $search . '%'); });
}