format('Ymdhis'), 2); do { $str = $str . mt_rand(10000, 99999); $res = self::where('order_number', $str)->first(); if(!$res) break; $times = $times - 1; } while($times); return $str; } public function user() { return $this->belongsTo('App\Models\User', 'user_id'); } public function workPoint() { return $this->belongsTo('App\Models\WorkPoint', 'work_point_id'); } public function getOrderStatus(Project $project, $user, $is_draft) { if($is_draft) { return Option::get('orders', 'status', 'checking'); } if($project->isTopLevel($user)) { return Option::get('orders', 'status', 'pass'); } return Option::get('orders', 'status', 'checking'); } }