public function filterResultCategory(Request $request) { $category_id = $request->category; $category = \Model\Category\ModelName::where('id', '=', $category_id)->first(); $lc = app()->getlocale(); $df = $request->dateFrom; $dt = $request->dateTo; $dateFrom = date('Y-m-d', strtotime($df)); $dateTo = date('Y-m-d', strtotime($dt)); $perPage = 10; $categories = \Model\Category\ModelName::all(); $backgroundMain = \Model\Background\ModelName::where('published', '=', true)->first(); if ($lc == 'kg' and $df != '' and $dt != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datefromkg($df)->datetokg($dt)->orderBy('id', 'desc')->paginate($perPage); } elseif ($lc == 'kg' and $df != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datefromkg($df)->orderBy('id', 'desc')->paginate($perPage); } elseif ($lc == 'kg' and $dt != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datetokg($dt)->orderBy('id', 'desc')->paginate($perPage); } elseif ($lc == 'ru' and $df != '' and $dt != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datefromru($df)->datetoru($dt)->orderBy('id', 'desc')->paginate($perPage); } elseif ($lc == 'ru' and $df != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datefromru($df)->orderBy('id', 'desc')->paginate($perPage); } elseif ($lc == 'ru' and $dt != '') { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->datetoru($dt)->orderBy('id', 'desc')->paginate($perPage); } else { $postAllFromTo = \Model\Post\ModelName::published()->where('category_id', '=', $category_id)->orderBy('id', 'desc')->paginate($perPage); } return view('Front::category.index', ['perPage' => $perPage, 'category' => $category, 'posts' => $postAllFromTo, 'categories' => $categories, 'backgroundMain' => $backgroundMain]); }