mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Alexusmai\LaravelFileManager\Services\ACLService\ACLRepository;
|
|
|
|
/**
|
|
* Class DBACLRepository
|
|
*
|
|
* @package Alexusmai\LaravelFileManager\Services\ACLService
|
|
*/
|
|
class DBACLRepository implements ACLRepository
|
|
{
|
|
/**
|
|
* Get user ID
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getUserID()
|
|
{
|
|
return \Auth::id();
|
|
}
|
|
|
|
public function getUserRank()
|
|
{
|
|
return \Auth::user()->rank_id;
|
|
}
|
|
|
|
public function getUserJobs()
|
|
{
|
|
return \Auth::user()->job_id;
|
|
}
|
|
|
|
/**
|
|
* Get ACL rules list for user
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getRules(): array
|
|
{
|
|
$rules = \DB::table('acl_rules')
|
|
->where('user_id', $this->getUserID())
|
|
->get(['disk', 'path', 'access'])
|
|
->map(function ($item) {
|
|
return get_object_vars($item);
|
|
})
|
|
->all();
|
|
$rank_rules = \DB::table('acl_rules')
|
|
->where('rank_id', $this->getUserRank())
|
|
->get(['disk', 'path', 'access'])
|
|
->map(function ($item) {
|
|
return get_object_vars($item);
|
|
})
|
|
->all();
|
|
$job_rules = \DB::table('acl_rules')
|
|
->where('job_id', $this->getUserJobs())
|
|
->get(['disk', 'path', 'access'])
|
|
->map(function ($item) {
|
|
return get_object_vars($item);
|
|
})
|
|
->all();
|
|
$all_rules = \DB::table('acl_rules')
|
|
->where('user_id', '=','*')
|
|
->get(['disk', 'path', 'access'])
|
|
->map(function ($item) {
|
|
return get_object_vars($item);
|
|
})
|
|
->all();
|
|
$rules = array_merge($rules,$rank_rules,$job_rules,$all_rules);
|
|
return $rules;
|
|
}
|
|
}
|