mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 18:59:09 -04:00
filesysteme
This commit is contained in:
72
app/Services/DBACLRepository.php
Normal file
72
app/Services/DBACLRepository.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user