1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Http\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsToMany;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Role extends Model
- {
- use SoftDeletes;
- protected $table = 'roles';
- protected $guarded = [];
- /**
- * A role may be given various permissions.
- */
- public function permissions(): BelongsToMany
- {
- return $this->belongsToMany(
- Permission::class,
- 'role_has_permissions',
- 'role_id',
- 'permission_id'
- );
- }
- public function users()
- {
- return $this->hasMany(User::class, 'role_id', 'id');
- }
- public function projects(): BelongsToMany
- {
- return $this->belongsToMany(
- Project::class,
- 'role_has_projects',
- 'project_id',
- 'permission_id'
- );
- }
- const TYPE_CLIENT = -1; //客户
- const TYPE_SELLER = 1; //销售
- const TYPE_AE = 2; //采编AE人员
- const TYPE_LINK_PART = 3; //外链兼职
- const TYPE_ARTICLE_PART = 4;//软文兼职
- const TYPE_CUSTOMER = 5; //客户
- const TYPE_MANAGER = 6; //项目总控
- const TYPE_SERVER = 7; //客服
- const TYPE_CHANNEL_BOSS = 8; //渠道老板
- const TYPE_AGENT_BOSS = 9;//代理商老板
- const TYPE_LINK_PART_CHONGQING = 13;//重庆兼职人员
- const TYPE_WEB = 14;//前端
- const TYPE_PROPAGANDA = 15;//品宣部
- const TYPE_BID = 16; //竞价人员
- const TYPE_ARTICLE = 17; //软文部
- const TYPE_LINK = 18; //外链部
- const TYPE_AGENT_MANAGER = 19;//代理商经理
- const TYPE_AGENT_WORKER = 20;//代理商员工
- const TYPE_CHANNEL_MANAGER = 21;//渠道经理
- const TYPE_CHANNEL_WORKER = 22;//渠道员工
- const TYPE_TYPE_CUSTOMER_STAFF = 23;//客户员工
- const TYPE_MANAGE_LEADER = 24;//项目总监
- const TYPE_MANAGE_HELPER = 25;//项目经理
- const TYPE_OPTIMIZER = 26;//优化师
- const TYPE_DESIGNER = 27;//设计师
- const TYPE_financial = 28;//财务
- const TYPE_PLANNER = 29;//策划
- const TYPE_QUALITY = 30;//质检
- const TYPE_DESIGN_DIRECTOR = 31;//设计总监
- const TYPE_OPTIMIZATION_EDITING = 32;//优化采编
- const TYPE_HR = 33;//hr
- const TYPE_SOFT_TEXT_SEARCH = 34;//软文查找
- const TYPE_BIDDING_MANAGER = 35;//竞价经理
- const TYPE_CHONGQING_MANAGER = 36;//重庆主管
- const TYPE_CHONGQING_LINK = 37;//重庆外链
- public static function getUsers($type)
- {
- $role = self::query()->where(['id' => $type])->first();
- if (!$role) return collect([]);
- return $role->users()->where(['status' => 1])->select(['id', 'username', 'nickname'])->get();
- }
- }
|