lukegalea16's avatar

Pagination and Search Table

Can someone please provide me with a suitable example which loads several records into an HTML table and has the option to search as well. Pagination should be used due to the large amount of records.

Thanks Luke

0 likes
2 replies
jlrdw's avatar

See https://drive.google.com/file/d/0B1_PFw--3o74YjVreHNBOWU2aEE/view?usp=sharing

It's just a form and passing the search parameters to model scope via controller.

You should also view the from scratch video series.

https://laracasts.com/series/laravel-6-from-scratch

@jeffreyway teaches basic crud (create, read, update, delete) techniques. Or take some basic crud tutorials.

Something like:

        $page = Request::input('page', '1');
        $dogsearch = !empty(Request::input('psch')) ? Request::input('psch') : '';
        $aval = !empty(Request::input('aval')) ? Request::input('aval') : '';
        $dogsch = $dogsearch . "%";

        $query = Dog::where('dogname', 'like', $dogsch);
        if ($aval == "n") {
            $query->where('adopted', '=', 1);
        } else if ($aval == "y") {
            $query->where('adopted', '=', 0);
        }
        $dogs = $query->orderBy('lastedit', 'DESC')->paginate(5);
        
        $params = array('psch' => $dogsearch, 'aval' => $aval);
        $title = 'Admin';

        /// and send to view

Just quick example, but I use query scopes in model when needed.

Please or to participate in this conversation.