belongsToMany( Permission::class, 'project_has_permissions', 'project_id', 'permission_id' ); } public function info(): HasOne { return $this->hasOne( ProjectInfo::class, 'project_id', 'id' ); } public function ae(): HasOne { return $this->hasOne( User::class, 'id', 'ae_id' ); } public function scopeProject(Builder $query, $projectIds = null) { if ($projectIds === null) { return $query; } return $query->where('id', $projectIds); } public function serialNo() { return sprintf('R%s-%s', date('Y'), $this->newQuery()->count()); } const COMPANY_TYPE = [ [ 'key' => 1, 'title' => '中小型企业' ], [ 'key' => 2, 'title' => '国企/上市公司' ] ]; }