📜  订单号生成 laravel - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:41.588000             🧑  作者: Mango

代码示例2
$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();