first(); if(!$station){ $station=new SortingStation(['name'=>$name]); $station->save(); } return $station; } public function login(){ $this['login_at'] = Carbon::now(); $this['is_online'] = '是'; $this->update(); } public function setProcessingBatch(Batch $batch){ $this['processing_batch_id'] = $batch['id']; $this['is_occupied'] = '是'; $this->login(); $this->update(); } public function clearProcessingBatch(){ $this['processing_batch_id'] = null; $this['is_occupied'] = '否'; $this->login(); $this->update(); } }