public function getAllPosts($lang, $postType)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess($postType, 'read')) {
            return $this->noPermission();
        }

        $defaultOrderBy = 'postID';
        $orderBy = (Input::get('order') ) ? Input::get('order') : $defaultOrderBy;
        $orderType = (Input::get('type')) ? Input::get('type') : 'DESC';
        $advancedSearch = (Input::get('advancedSearch')) ? Input::get('advancedSearch') : false;
        $categoryID = (Input::get('categoryID')) ? Input::get('categoryID') : null;

        // get field type in db
        try{
            $orderColumnType = DB::connection()->getDoctrineColumn($postType, $orderBy)->getType()->getName();
        }catch (\Exception $e){
            $orderColumnType = false;
            $orderBy = $defaultOrderBy;
        }

        // make the query
        $queryObject =  (new Post())->setTable($postType);
        // get user relation
        $queryObject = $queryObject->with("users");

        // get categories relations (if post type has categories)
        $postTypeOBJ = getPostType($postType);
        if($postTypeOBJ->hasCategories) {
            $queryObject = $queryObject->with("categories");
        }

        // Advanced Search
        if($advancedSearch) {
            $queryObject = $this->advancedSearch($queryObject, request(), $postType);
        }else if($categoryID) {
            // select based on categories
            $queryObject = $this->selectByCategory($queryObject, $categoryID, $postType);
        }

        // json langauge fields needs to be filtered by their langauge
        if($orderColumnType == "json") {
            $queryObject = $queryObject->orderBy($orderBy."->".App::getLocale(), $orderType);
        }else{
            $queryObject = $queryObject->orderBy($orderBy, $orderType);
        }

        // paginate
        $paginationResult = $queryObject->paginate(Post::$rowsPerPage);

        $response = $this
            ->appendListColumnsFromEvents($postType)
            ->appendListRowsFromEvents($paginationResult, $postType)
            ->toArray();

        $response['inTableColumns'] = $this->getInTableColumns($postType);

        $lang = App::getLocale();
        // set category title and author name
        foreach ($response['data'] as $key => $item){
            if(isset($item['categories']) && count($item['categories'])) {
                array_set($response, "data.$key.category", $item['categories'][0]['title']->$lang);
            }
            array_set($response, "data.$key.author", $item['users']['firstName'] . " ". $item['users']['lastName']);
        }

        return $response;
    }
public function getAllPosts($lang, $postType)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess($postType, 'read')) {
            return $this->noPermission();
        }

        $defaultOrderBy = 'postID';
        $orderBy = (Input::get('order') ) ? Input::get('order') : $defaultOrderBy;
        $orderType = (Input::get('type')) ? Input::get('type') : 'DESC';
        $advancedSearch = (Input::get('advancedSearch')) ? Input::get('advancedSearch') : false;
        $categoryID = (Input::get('categoryID')) ? Input::get('categoryID') : null;

        // get field type in db
        try{
            $orderColumnType = DB::connection()->getDoctrineColumn($postType, $orderBy)->getType()->getName();
        }catch (\Exception $e){
            $orderColumnType = false;
            $orderBy = $defaultOrderBy;
        }

        // make the query
        $queryObject =  (new Post())->setTable($postType);
        // get user relation
        $queryObject = $queryObject->with("users");

        // get categories relations (if post type has categories)
        $postTypeOBJ = getPostType($postType);
        if($postTypeOBJ->hasCategories) {
            $queryObject = $queryObject->with("categories");
        }

        // Advanced Search
        if($advancedSearch) {
            $queryObject = $this->advancedSearch($queryObject, request(), $postType);
        }else if($categoryID) {
            // select based on categories
            $queryObject = $this->selectByCategory($queryObject, $categoryID, $postType);
        }

        // json langauge fields needs to be filtered by their langauge
        if($orderColumnType == "json") {
            $queryObject = $queryObject->orderBy($orderBy."->".App::getLocale(), $orderType);
        }else{
            $queryObject = $queryObject->orderBy($orderBy, $orderType);
        }

        // paginate
        $paginationResult = $queryObject->paginate(Post::$rowsPerPage);

        $response = $this
            ->appendListColumnsFromEvents($postType)
            ->appendListRowsFromEvents($paginationResult, $postType)
            ->toArray();

        $response['inTableColumns'] = $this->getInTableColumns($postType);

        $lang = App::getLocale();
        // set category title and author name
        foreach ($response['data'] as $key => $item){
            if(isset($item['categories']) && count($item['categories'])) {
                array_set($response, "data.$key.category", $item['categories'][0]['title']->$lang);
            }
            array_set($response, "data.$key.author", $item['users']['firstName'] . " ". $item['users']['lastName']);
        }

        return $response;
    }
public function getAllPosts ( $ lang , $ postType ) { // check if user has permissions to access this link if ( ! User :: hasAccess ( $ postType , 'read' ) ) { return $ this -> noPermission ( ) ; } $ defaultOrderBy = 'postID' ; $ orderBy = ( Input :: get ( 'order' ) ) ? Input :: get ( 'order' ) : $ defaultOrderBy ; $ orderType = ( Input :: get ( 'type' ) ) ? Input :: get ( 'type' ) : 'DESC' ; $ advancedSearch = ( Input :: get ( 'advancedSearch' ) ) ? Input :: get ( 'advancedSearch' ) : false ; $ categoryID = ( Input :: get ( 'categoryID' ) ) ? Input :: get ( 'categoryID' ) : null ; // get field type in db try { $ orderColumnType = DB :: connection ( ) -> getDoctrineColumn ( $ postType , $ orderBy ) -> getType ( ) -> getName ( ) ; } catch ( \ Exception $ e ) { $ orderColumnType = false ; $ orderBy = $ defaultOrderBy ; } // make the query $ queryObject = ( new Post ( ) ) -> setTable ( $ postType ) ; // get user relation $ queryObject = $ queryObject -> with ( "users" ) ; // get categories relations (if post type has categories) $ postTypeOBJ = getPostType ( $ postType ) ; if ( $ postTypeOBJ -> hasCategories ) { $ queryObject = $ queryObject -> with ( "categories" ) ; } // Advanced Search if ( $ advancedSearch ) { $ queryObject = $ this -> advancedSearch ( $ queryObject , request ( ) , $ postType ) ; } else if ( $ categoryID ) { // select based on categories $ queryObject = $ this -> selectByCategory ( $ queryObject , $ categoryID , $ postType ) ; } // json langauge fields needs to be filtered by their langauge if ( $ orderColumnType == "json" ) { $ queryObject = $ queryObject -> orderBy ( $ orderBy . "->" . App :: getLocale ( ) , $ orderType ) ; } else { $ queryObject = $ queryObject -> orderBy ( $ orderBy , $ orderType ) ; } // paginate $ paginationResult = $ queryObject -> paginate ( Post :: $ rowsPerPage ) ; $ response = $ this -> appendListColumnsFromEvents ( $ postType ) -> appendListRowsFromEvents ( $ paginationResult , $ postType ) -> toArray ( ) ; $ response [ 'inTableColumns' ] = $ this -> getInTableColumns ( $ postType ) ; $ lang = App :: getLocale ( ) ; // set category title and author name foreach ( $ response [ 'data' ] as $ key => $ item ) { if ( isset ( $ item [ 'categories' ] ) && count ( $ item [ 'categories' ] ) ) { array_set ( $ response , "data.$key.category" , $ item [ 'categories' ] [ 0 ] [ 'title' ] -> $ lang ) ; } array_set ( $ response , "data.$key.author" , $ item [ 'users' ] [ 'firstName' ] . " " . $ item [ 'users' ] [ 'lastName' ] ) ; } return $ response ; }
Get all post of a post type.

TODO: me shti ne funksion ElasticSearch

@param  string $lang     language slug
@param  string $postType post type slug
@return array post data
Get all post of a post type .