lundi 18 novembre 2019

How to call the view result of pagination in Laravel?

HI, I'm new to code, i want to know how to call the result and view the pagination, i had observed around and couldn't find a solution on this, can someone help me out, Thanks

Here is my index.blade.php coding

        @foreach($category as $row)

            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>

                <td><a href="" class="btn btn-warning">Edit</a></td>
                <td>
                    <form method="post" class="delete_form" action="">
                        
                        

                        <input type="hidden" name="_method" value="DELETE"  />
                        <button type="submit" class="btn btn-danger">Delete</button>
                    </form>
                </td>
            </tr>
        @endforeach
    </table>

    <ul class="pagination justify-content-end">
        
    </ul>

My error picture: Error picture

Before adding the code , Interface be like :Interface

// categoryController.php
public function index(Request $request)
{
    $codeSearch = $request->get('code');
    $descriptionSearch = $request->get('description');

    // $tmp = Category::all()->toArray();
    $tmp = Category::where('code','like','%' .$codeSearch. '%')->where('description','like','%' .$codeSearch. '%')->paginate(10);

    $category = array();
        foreach ($tmp as $key => $row) {
        $policy = Category::find($row['parent_id']);

        $tmpResult = new Category();
        $tmpResult->id = $row['id'];
        $tmpResult->code = $row['code'];
        $tmpResult->description = $row['description'];
        $tmpResult->parent_id = $policy['description'];
        $tmpResult->status = $row['status'];
        array_push($category, $tmpResult);
    }

    return view('category.index', compact('category'));
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire