setAttrs($params); $model->store_id = request()->adminInfo['store_id']; $defaultAvatar = config('project.default_image.admin_avatar'); $model->avatar = !empty($model['avatar']) ? FileService::setFileUrl($model['avatar']) : $defaultAvatar; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function edit($id, $params) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->setAttrs($params); $defaultAvatar = config('project.default_image.admin_avatar'); $model->avatar = !empty($model['avatar']) ? FileService::setFileUrl($model['avatar']) : $defaultAvatar; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function delete($id) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->delete(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function detail($id) { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } return $model->toArray(); } public function status($id) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->status = $model->status == 1 ? 0 : 1; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } }