Reputation: 1818
How can I create a query random with laravel and exclude a specific row
I tried this :
return $this->user
->get()
->random(1)
->where('id', '!=', 1);
Upvotes: 1
Views: 259
Reputation: 12246
You're where needs to be first.
return $this->movie::where('id', '!=', 1)
->get()
->random(1);
Upvotes: 3