Laravel pagination with problems - TechRepublic
Question
March 31, 2021 at 12:00 PM
belmeska

Laravel pagination with problems

by belmeska . Updated 5 years, 2 months ago

i have a simple question as i do not know which line i should add into to get laravel pagination. (->paginate(5). Wonderful source to read. It helped me a lot, but still… https://.com/laravel/laravel-overwriting-default-pagination-system

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. ‘%’)->get()->toArray();

$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’));
}

Moderator Note: URL disabled so this is not spam.

This discussion is locked

All Comments