order number generate laravel

Solutions on MaxInterview for order number generate laravel by the best coders in the world

showing results for - "order number generate laravel"
Matteo
18 Feb 2020
1public function get_order_number()
2{
3    return '#' . str_pad($this->id, 8, "0", STR_PAD_LEFT);
4}
Rafaela
18 Aug 2017
1$order = new Order;
2
3$order->user_id = Auth()->id();
4$latestOrder = App\Order::orderBy('created_at','DESC')->first();
5$order->order_nr = '#'.str_pad($latestOrder->id + 1, 8, "0", STR_PAD_LEFT);
6$order->save();