Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagination example #62

Open
ghost opened this issue Nov 8, 2015 · 2 comments
Open

pagination example #62

ghost opened this issue Nov 8, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 8, 2015

can you show a pagination example usage please ?

@ghost
Copy link
Author

ghost commented Nov 8, 2015

okey i found a way to do it, i am using laravel for my projects

this code is just a sample and not a good one but it works

if anyone knows a better code please share

    <?php

    namespace App\Http\Controllers;

    use App\Http\Controllers\Controller;
    use Illuminate\Http\Request;
    use Illuminate\Pagination\LengthAwarePaginator;
    use Tumblr;

    class HomeController extends Controller {

        public function index($blogName, Request $request) {
            $page = $request->input('page');

            $consumerKey = 'ps3J8J';
            $consumerSecret = 'dqcrP3';
            $client = new Tumblr($consumerKey, $consumerSecret);

            $post = $client->getBlogPosts($blogName, [
                'limit' => 20,
                'offset' => $page * 20,
            ]);

            $blog = (new LengthAwarePaginator($post->posts, 20000, 20, $page, ['path' => $request->url()]));

            return view('home', compact('blog', 'post'));
        }

@vitor-mariano
Copy link

Your code looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant