laravel db inserr
DB::table('users')->insert([
'email' => '[email protected]',
'votes' => 0
]);
laravel db inserr
DB::table('users')->insert([
'email' => '[email protected]',
'votes' => 0
]);
laravel orWhere
$camps = $field->camps()->where('status', 0)->where(function ($q) {
$q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->get();
laravel not in query
DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
AND-OR-AND + brackets with Eloquent
//mysql query be like this
// ... WHERE (gender = 'Male' and age >= 18) or (gender = 'Female' and age >= 65)
//Eloquent query is
// ...
$q->where(function ($query) {
$query->where('gender', 'Male')
->where('age', '>=', 18);
})->orWhere(function($query) {
$query->where('gender', 'Female')
->where('age', '>=', 65);
})
//@sujay
where in laravel
$users = Users::whereIn('id', array(1, 2, 3))->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();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us