model = new NotebookUser(); } /** * @return array */ public function lists(): array { $query = $this->model->join('administrators', 'administrators.id', '=', "notebook_user.administrators_id") ->select([ "notebook_user.id","notebook_user.notebook_id","notebook_user.administrators_id","notebook_user.mode","notebook_user.status","notebook_user.create_time","administrators.name as user" ]); if (Hy::request()->query('notebook_id')) { $query->where("notebook_user.notebook_id", Hy::request()->query('notebook_id')); } return EasySearch::create($query)->totalCancellations()->getData()['data']->toArray(); } /** * @param $data * @param $id * * @return void * @throws ApiMessageException */ public function beforeUpdate(&$data, $id): void { if ($this->model->notebook->administrators_id != AdminAuth::getInfo()->id) { throw new ApiMessageException('对不起,未找到该操作'); } } /** * @param array $ids * * @return void * @throws ApiMessageException */ public function beforeDestroy(array $ids): void { $data = NotebookUser::whereIn('id', $ids)->pluck('notebook_id'); $notAuth = Notebook::whereIn('id', $data->toArray()) ->where('administrators_id', '<>', AdminAuth::getInfo()->id) ->value('id'); if ($notAuth) { throw new ApiMessageException('对不起,未找到该操作'); } } }