logan
0
Q:

in random order laravel

$order = new Order;

$order->user_id = Auth()->id();
$latestOrder = App\Order::orderBy('created_at','DESC')->first();
$order->order_nr = '#'.str_pad($latestOrder->id + 1, 8, "0", STR_PAD_LEFT);
$order->save();
2
User::all()->random();
User::all()->random(10); // The amount of items you wish to receive
1
public function get_order_number()
{
    return '#' . str_pad($this->id, 8, "0", STR_PAD_LEFT);
}
1
$galleries = App\Gallery::inRandomOrder()->get();
//Or
DB::table('gallery')->inRandomOrder()->get();
0
Model::select('column')->where('column','value')->inRandomOrder()
    ->limit(2) // here is yours limit
    ->get();

------------------ OR --------------------

Model::inRandomOrder()->select('column')->where('column','value')->first();
0

New to Communities?

Join the community