Support the ongoing development of Laravel.io →
posted 2 years ago
Database
Last updated 8 months ago.
0

First use " Illuminate\Support\Facades\DB " Then write DB::select('select * from hotel_reception where !(status != 0 and tag = "reserve")' );

0

No, I do not want that

Please refer to Laravel codes

I do not want the output to be array

0
moderator

If you want to group the where statements you can use a closure.

Not tested example:

Reception::whereNot(static function ($query) {
    $query->whereNot('status', 0)
        ->where('tag', 'reserve');
})->get();
1

you can do in many ways suppose you can write with DB::select('write raw sql'), with DB::raw ('write raw sql'), and also you can write eloquent model

Solution is

$receptions = Reception::where([
'hotel_id' => $hotel_id,
'payed'=> 1
])->whereNot('staying_time', 0)->get();

You can also use 'Dazzler' and 'Tobias van Beek' Solution. both is also right

0

Sign in to participate in this thread!

Cloudways

Your banner here too?

mostafa mhml1367 Joined 12 Sep 2020

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.

© 2023 Laravel.io - All rights reserved.