|
@@ -111,7 +111,8 @@ class User extends Authenticatable
|
|
|
});
|
|
});
|
|
|
return $authorities;
|
|
return $authorities;
|
|
|
}
|
|
}
|
|
|
- function getPermittingOwnerIdsAttribute(){
|
|
|
|
|
|
|
+ function getPermittingOwnerIdsAttribute(): array
|
|
|
|
|
+ {
|
|
|
$ownerIds=[];
|
|
$ownerIds=[];
|
|
|
if($this->isSuperAdmin()||Gate::allows('货主-可见全部')){
|
|
if($this->isSuperAdmin()||Gate::allows('货主-可见全部')){
|
|
|
$owners=Owner::query()->whereNull('deleted_at')->get();
|
|
$owners=Owner::query()->whereNull('deleted_at')->get();
|
|
@@ -135,7 +136,8 @@ class User extends Authenticatable
|
|
|
}
|
|
}
|
|
|
return array_unique(array_merge($ownerIds, $old_owner));
|
|
return array_unique(array_merge($ownerIds, $old_owner));
|
|
|
}
|
|
}
|
|
|
- function getPermittingWorkgroupIds($allowAll=false){
|
|
|
|
|
|
|
+ function getPermittingWorkgroupIds($allowAll=false): array
|
|
|
|
|
+ {
|
|
|
$workgroupIds=[];
|
|
$workgroupIds=[];
|
|
|
if ($this->isSuperAdmin()||$allowAll){
|
|
if ($this->isSuperAdmin()||$allowAll){
|
|
|
$workgroups=UserWorkgroup::all();
|
|
$workgroups=UserWorkgroup::all();
|
|
@@ -151,6 +153,7 @@ class User extends Authenticatable
|
|
|
}
|
|
}
|
|
|
return $workgroupIds;
|
|
return $workgroupIds;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function getPermittingLaborCompanyIdsAttribute(): array
|
|
function getPermittingLaborCompanyIdsAttribute(): array
|
|
|
{
|
|
{
|
|
|
$labor_company_ids=array();
|
|
$labor_company_ids=array();
|
|
@@ -170,6 +173,15 @@ class User extends Authenticatable
|
|
|
return array_unique($labor_company_ids);
|
|
return array_unique($labor_company_ids);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 用户可见货主
|
|
|
|
|
+ public function getPermittingLogisticIdsAttribute(): array
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->isSuperAdmin()){
|
|
|
|
|
+ return Logistic::query()->get()->map(function($logistic){return $logistic->id;})->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->logistics()->get()->map(function($logistic){return $logistic->id;})->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function workGroups()
|
|
public function workGroups()
|
|
|
{
|
|
{
|
|
|
return $this->morphedByMany(UserWorkgroup::class, 'user_authable');
|
|
return $this->morphedByMany(UserWorkgroup::class, 'user_authable');
|