Not showing any error just redirecting me to the homepage whenever I hit http://127.0.0.1:8000/news even I tried to dump under the function index but redirected me to the homepage
<?php
return [
'news_route_prefix' => env("NEWS_ROUTER_PREFIX","news"),
'news_category_route_prefix' => env("NEWS_CATEGORY_ROUTER_PREFIX","category"),
'news_tag_route_prefix' => env("NEWS_TAG_ROUTER_PREFIX","tag"),
'news_comment_route_prefix' => env("NEWS_COMMENT_ROUTER_PREFIX","comment"),
];
Route::group(['prefix' => config('news.news_route_prefix')],function(){
Route::get('/',[NewsController::class, 'index'])->name('news.index');
});
public function index(Request $request)
{
$model_News = News::query()->select("news.*");
$model_News->where("news.status", "publish")->orderBy('news.id', 'desc');
if (!empty($search = $request->input("s"))) {
$model_News->where(function($query) use ($search) {
$query->where('news.title', 'LIKE', '%' . $search . '%');
$query->orWhere('news.content', 'LIKE', '%' . $search . '%');
});
$title_page = __('Search results : ":s"', ["s" => $search]);
}
$data = [
'rows' => $model_News->with("getAuthor")->paginate(5),
'model_category' => NewsCategory::query()->where("status", "publish"),
'model_tag' => Tag::query(),
'model_news' => News::query()->where("status", "publish"),
'custom_title_page' => $title_page ?? "",
"seo_meta" => News::getSeoMetaForPageList(),
];
return view('News::frontend.index', $data);
}
POST news ................................................... news.comment.store › Modules\News\Controllers\CommentNewsController@store
GET|HEAD news .................................................................. news.index › Modules\News\Controllers\NewsController@index
GET|HEAD news/category/{slug} ................................. news.category.index › Modules\News\Controllers\CategoryNewsController@index
GET|HEAD news/tag/{slug} ................................................ news.tag.index › Modules\News\Controllers\TagNewsController@index
GET|HEAD news/{slug} ......................................................... news.detail › Modules\News\Controllers\NewsController@detail
CodePudding user response:
if you are redirected even making die and dump in index method that means the incoming request never be recieved in controller and in the middleware is redirected. Check what middlewares your route is using. Maybe it's a group middleware . I hope this works.