Home > OS >  Unique query for one record
Unique query for one record

Time:09-23

I need to turn off the "where" for one entry that I know of. I don’t understand how to do this. To understand the general problem: I need a collection with all the records a unique one for which the "where" has not been applied. They should be displayed in the usual manner. Perhaps there is a solution to add this entry to the collection after querying sort the new collection?

     $reviews = Review::query()
            ->orderBy("id", 'desc')
            ->whereNotNull('published_at')
             //But don't apply whereNotNull ('published_at') to a record with id = ...
            ->get()

CodePudding user response:

$reviews = Review::query()
            ->orderBy("id", 'desc')
            ->whereNotNull('published_at')
            ->orWhere('id', $your_id_here)
            ->get()

Is it what you are looking for? It will get all records where published_at is not null or where the id is $your_id_here.

  • Related