'单位',2=>'个人']; public $cate = [1=>'咨询费',2=>'咨询服务费',3=>'服务费']; public function model() { return Invoice::class; } public function boot() { $this->pushCriteria(app(RequestCriteria::class)); } public function getOne($order_id, $user) { $cate = $this->getCate(); $cateaArr = array_column($cate, 'categoryname', 'id'); $where['order_num'] = $order_id; $where['uid'] = $user->id; $info = $this->model->where($where)->first(); if ($info) { $info->title = $this->title_arr[$info->title]; $info->cate = $cateaArr[$info->cid]; return $info; } else { return false; } } public function getOneInvoice($order_id, $user) { $where['order_num'] = $order_id; $where['uid'] = $user->id; return $this->model->where($where)->first(); } public function getCate() { return InvoiceCategory::select(['id','categoryname'])->get()->toArray(); } }