public function getList(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('permissions', 'read')) {
            return $this->noPermission();
        }
        $className = 'App\\Models\\'.$request->customPermissions['model'];
        $class = new $className(); // generated class from model name
        $currentLang = App::getLocale();
        $obj = DB::table($class->table);
        // where clause
        if (isset($request->customPermissions['keys'])) {
            foreach ($request->customPermissions['keys'] as $clause){
                $obj->where($clause['field'], $clause['operator'], $clause['value']);
            }
        }
        // order
        if (isset($request->customPermissions['order'])) {
            foreach ($request->customPermissions['order'] as $orderKey => $order){
                if(isset($order['isTranslatable']) && $order['isTranslatable']) {
                    $obj->orderBy($order['field'].'->'.$currentLang, $order['type']);
                }else{
                    $obj->orderBy($order['field'], $order['type']);
                }
            }
        }
        // limit
        if (isset($request->customPermissions['limit'])) {
            $obj->limit($request->customPermissions['limit']);
        }
        // push primary key in selected
        $selected = $request->customPermissions['select'];
        array_push($selected, $class->getKeyName());
        $list = $obj->select($selected)->get();
        // filter by language
        $filteredArr = Language::filterRows($list, false);

        // construct result array
        $result = array();
        foreach ($filteredArr as $k => $filtered){
            $title = '';
            foreach ($filtered as $key => $value){
                if(in_array($key, $request->customPermissions['select'])) {
                    $title .= ($title != '') ? ' ' : '';
                    $title .= $value;
                }
            }
            array_push(
                $result, array(
                $class->primaryKey => $filtered[$class->getKeyName()],
                'title' => $title
                )
            );

        }
        return $result;
    }
public function getList(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('permissions', 'read')) {
            return $this->noPermission();
        }
        $className = 'App\\Models\\'.$request->customPermissions['model'];
        $class = new $className(); // generated class from model name
        $currentLang = App::getLocale();
        $obj = DB::table($class->table);
        // where clause
        if (isset($request->customPermissions['keys'])) {
            foreach ($request->customPermissions['keys'] as $clause){
                $obj->where($clause['field'], $clause['operator'], $clause['value']);
            }
        }
        // order
        if (isset($request->customPermissions['order'])) {
            foreach ($request->customPermissions['order'] as $orderKey => $order){
                if(isset($order['isTranslatable']) && $order['isTranslatable']) {
                    $obj->orderBy($order['field'].'->'.$currentLang, $order['type']);
                }else{
                    $obj->orderBy($order['field'], $order['type']);
                }
            }
        }
        // limit
        if (isset($request->customPermissions['limit'])) {
            $obj->limit($request->customPermissions['limit']);
        }
        // push primary key in selected
        $selected = $request->customPermissions['select'];
        array_push($selected, $class->getKeyName());
        $list = $obj->select($selected)->get();
        // filter by language
        $filteredArr = Language::filterRows($list, false);

        // construct result array
        $result = array();
        foreach ($filteredArr as $k => $filtered){
            $title = '';
            foreach ($filtered as $key => $value){
                if(in_array($key, $request->customPermissions['select'])) {
                    $title .= ($title != '') ? ' ' : '';
                    $title .= $value;
                }
            }
            array_push(
                $result, array(
                $class->primaryKey => $filtered[$class->getKeyName()],
                'title' => $title
                )
            );

        }
        return $result;
    }
public function getList ( Request $ request ) { // check if user has permissions to access this link if ( ! User :: hasAccess ( 'permissions' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ className = 'App\\Models\\' . $ request -> customPermissions [ 'model' ] ; $ class = new $ className ( ) ; // generated class from model name $ currentLang = App :: getLocale ( ) ; $ obj = DB :: table ( $ class -> table ) ; // where clause if ( isset ( $ request -> customPermissions [ 'keys' ] ) ) { foreach ( $ request -> customPermissions [ 'keys' ] as $ clause ) { $ obj -> where ( $ clause [ 'field' ] , $ clause [ 'operator' ] , $ clause [ 'value' ] ) ; } } // order if ( isset ( $ request -> customPermissions [ 'order' ] ) ) { foreach ( $ request -> customPermissions [ 'order' ] as $ orderKey => $ order ) { if ( isset ( $ order [ 'isTranslatable' ] ) && $ order [ 'isTranslatable' ] ) { $ obj -> orderBy ( $ order [ 'field' ] . '->' . $ currentLang , $ order [ 'type' ] ) ; } else { $ obj -> orderBy ( $ order [ 'field' ] , $ order [ 'type' ] ) ; } } } // limit if ( isset ( $ request -> customPermissions [ 'limit' ] ) ) { $ obj -> limit ( $ request -> customPermissions [ 'limit' ] ) ; } // push primary key in selected $ selected = $ request -> customPermissions [ 'select' ] ; array_push ( $ selected , $ class -> getKeyName ( ) ) ; $ list = $ obj -> select ( $ selected ) -> get ( ) ; // filter by language $ filteredArr = Language :: filterRows ( $ list , false ) ; // construct result array $ result = array ( ) ; foreach ( $ filteredArr as $ k => $ filtered ) { $ title = '' ; foreach ( $ filtered as $ key => $ value ) { if ( in_array ( $ key , $ request -> customPermissions [ 'select' ] ) ) { $ title .= ( $ title != '' ) ? ' ' : '' ; $ title .= $ value ; } } array_push ( $ result , array ( $ class -> primaryKey => $ filtered [ $ class -> getKeyName ( ) ] , 'title' => $ title ) ) ; } return $ result ; }
USED to get list of models for custom permissions.
Returns array list from DB with primary key as array key and selected columns as value.

@param  Request $request
@return array
USED to get list of models for custom permissions . Returns array list from DB with primary key as array key and selected columns as value .