I cannot find the way to display random results from a collection in laravel mysql. My query:
public function getTabletsProducts()
{
return DB::table('products')
->orderBy('created_at')
->where('categoryName', 'All Tablets')
->where('sellingPrice', '<', 1000)
->take(6)
->orderByRaw("RAND()")
->get();
}
They weird thing is that I believed that using RAND would perform the job, but my results display same values using or not (rand).
any help appreciated.