OvalUK / PHP_Laravel_Pagination by jamestrusleroval

Pagination helper library for Laravel
745
1
3
Package Data
Maintainer Username: jamestrusleroval
Package Create Date: 2014-08-26
Package Last Update: 2015-01-13
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:21:24
Package Statistics
Total Downloads: 745
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

PHP_Laravel_Pagination

Include our library using the composer name: oval/laravel-pagination

View:

$Model->items was passed from our controller and contains the response from the database(see model)

<?=$Model->items->appends( Input::except('page') )->links();?>

Controller:

Here is an example of a controller method

public function Test()
{
    
    $paginationViewModel = new PaginationViewModel();
    $paginationModel = new PaginationModel();
    
    $paginationModel->amount = 50;
    $paginationModel->columns[ "projectTitle" ] = new PaginationColumn( "project_title", Input::get( "projectTitle" ), Input::get('projectTitleSort') );
    $paginationModel->columns[ "partners" ] = new PaginationColumn( "partners", Input::get( "partners" ), Input::get('partnersSort') );        
    $paginationModel->page = isset( $_GET[ "page" ] ) ? $_GET[ "page" ] : 0;
    
    $paginationViewModel->paginationModel = $paginationModel;
    $paginationViewModel->items = $this->yourRepository->GetWithPagination( $paginationModel );
    
    return View::make('whatever/test', array( "Model" => $paginationViewModel ) );
    
}

Model:

This is the GetWithPagination method we set up in our "yourRepository"

public function GetWithPagination( PaginationModel $paginationModel )
{
    $query = DB::table('tablename');   
    $whatevers = $query->paginate( PaginationHelper::PrepareForDb( $query, $paginationModel ) );
    return $whatevers;
}