Answer the question
In order to leave comments, you need to log in
Strange behavior of routes in laravel 5.3?
Good afternoon, there is a route Route::get('/search','[email protected]');
There is a search function in the ArchiveController controller
protected function search(Request $request){
$search = $request->search;
$style_s = $request->style;
$country_s = $request->country;
$year = $request->year;
$author = $request->author;
$albums_count = DB::table('archive')->count();
$albums = DB::table('archive')->when($search, function ($query) use ($search) {
return $query->where('artist', $search);
})->when($style_s, function ($query) use ($style_s) {
return $query->where('style', $style_s);
})->when($country_s, function ($query) use ($country_s) {
return $query->where('country', $country_s);
})->when($year, function ($query) use ($year) {
return $query->where('year', $year);
})->when($author, function ($query) use ($author) {
return $query->where('author', $author);
})->orwhere('album', $search)->orderby('id',false)->paginate(9) ;
$country = Country::all('name')->sortBy('name');
$year = Year::all('name')->sortByDesc('name');
$style = Style::all('name')->sortBy('name');
return view('albums.index', ['albums' => $albums, 'albums_count' => $albums_count, 'style' => $style, 'country' => $country, 'year' => $year]);
}
<form class="form-inline" method="get" id="search" action="/search">
<form class="form-inline" method="get" id="search" action="/albums/search">
Route::get('/albums/search','[email protected]');
Answer the question
In order to leave comments, you need to log in
Maybe because you have another route Route::get('/albums/{any} ', '[email protected]'); ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question