Ejemplo n.º 1
0
Archivo: ACL.php Proyecto: groovey/acl
 public function authorize($userId)
 {
     $app = $this->app;
     $datas = DB::table('users as u')->select(['p.role_id', 'p.node', 'p.item', 'p.value', DB::raw("CONCAT(p.node,'.', p.item) as permission")])->leftJoin('roles as r', 'u.role_id', '=', 'r.id')->leftJoin('permissions as p', 'u.role_id', '=', 'p.role_id')->where('u.id', '=', $userId)->get();
     $permissions = [];
     foreach ($datas as $data) {
         $permissions[$data->permission] = (array) $data;
     }
     return self::$permissions = $permissions;
 }
Ejemplo n.º 2
0
 public function getRecords()
 {
     $app = $this->app;
     $page = $app['request']->get('page', 1);
     $sql = $this->getSql();
     $select = element('select', $sql);
     $from = element('from', $sql);
     $limit = element('limit', $sql);
     $totalRecords = $this->getTotalRecords();
     $where = $this->composeWhere();
     $group = $this->composeGroup();
     $order = $this->composeOrder();
     $app['paging']->limit($limit);
     $app['paging']->process($page, $totalRecords);
     $offset = $app['paging']->offset();
     $limit = $app['paging']->limit();
     $query = "SELECT {$select} FROM {$from} WHERE {$where} {$group} {$order} LIMIT {$offset}, {$limit}";
     $app['trace']->debug('getRecords = ' . $query);
     $app['trace']->debug('total = ' . $totalRecords);
     return DB::select($query);
 }