ThinkMe / pagination

Laravel5 pagination on steroids
2 stars 0 forks source link

Error in Laravel 5.4 #2

Closed JibrilYasin closed 6 years ago

JibrilYasin commented 6 years ago

Hi @ThinkMe ,, sorry,, Can you help me? I get an error on laravel 5.4.

ErrorException Declaration of App\Paginator::links() should be compatible with Illuminate\Pagination\LengthAwarePaginator::links($view = NULL, $data = Array)

This is my Controller <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use Illuminate\Support\Facades\DB;

use App\Http\Requests; use App\Services\Date; use App\Services\Code; use JavaScript; use Session; use Image; use File; use App\User; use Auth; use Mail; use Hash; use DateTime; use App\Paginator;

class UserController extends Controller {

public function users(Request $request){

        $query=User::get_data();
        $list = new Paginator();
        $list->route('myusers')->pagesProximity(5)->paginate($query, 5);

        $data['users']=$list;
        $data['pagination']=$list->render();

}

}

Thanks for attention..

ThinkMe commented 6 years ago

The version I use is also laravel 5.4. Look at the namespace use ThinkMe\Pagination\Paginator;

in views
index.blade.php common/paginate.blade.php

{!!$list->render('common.paginate')!!} or {!!$list->links('common.paginate')!!}

Where is your paging template?

JibrilYasin commented 6 years ago

Hi,, this is my view

{!! $pagination !!}

ThinkMe commented 6 years ago

a paging template paginate.blade.php

JibrilYasin commented 6 years ago

paginate.blade.php

@if ($paginator->lastPage() > 1)

@endif

ThinkMe commented 6 years ago

$list->render('paginate') or $list->links('paginate')

JibrilYasin commented 6 years ago

i use,, $list->links('paginate'),,

Yeahh now work, but in the url there is no parameter like "/2 or/3",, Just http://localhost/laravel/5.4/back-users?page=2

ThinkMe commented 6 years ago
    use ThinkMe\Pagination\Paginator;
    $list = new Paginator();
    $query = Order::select();
    $list->route('list.page')->pagesProximity(3)->paginate($query, 10);
    dd($list->appends(request()->all())->links('paginate'));

  route.php
  Route::get('user/{page}', ['as' => 'list.page', 'uses' => 'IndexController@index']);
JibrilYasin commented 6 years ago

The result

HtmlString {#65 ▼

html: ""

}

JibrilYasin commented 6 years ago

yeaah,, solved,, I forgot to add the parameters on the route. thanks @ThinkMe

JibrilYasin commented 6 years ago

Route::get('/back-users/{page?}'