Can you please assist, I have laravel project working fine in my localhost where am using wamp.The problem arise after uploading the project to cpanel it says 404 Not found to new routes i just added and others works fine. I tried stackoverflow asked questions where the found .htaccess solutions but still didn’t help.
Error 404 Not Found Screenshot
**Here is my Web.php file**
<?php
use IlluminateSupportFacadesRoute;
use AppHttpControllersExcelController;
//admin
Route::group(['middleware' => ['auth', 'role:admin'] ], function() {
Route::get('/admin/clientsaccounts', 'AppHttpControllersAdminController@accountsHome')->name('admin.clientsaccounts.index');
Route::get('/admin/accstatements', 'AppHttpControllersAdminController@statements')->name('admin.accstatements.index');
});
Controller
public function statements(Request $request){
$search = $request->input('search');
$custacc =DB::table('customers')
->select('customers.*')
->where('customers.firstname', 'LIKE', "%{$search}%")
->orWhere('customers.surname', 'LIKE', "%{$search}%")
->orWhere('customers.idnumber', 'LIKE', "%{$search}%")
->orderby('customers.created_at', 'desc')
->get();
return view('admin.statements.index')->with(compact('custacc'));
}
public function accountsHome(Request $request){
$search = $request->input('search');
$custacc =DB::table('accounts')
->join('customers', 'accounts.idnumber', '=', 'customers.idnumber')
->select('customers.*', 'accounts.*')
->where('customers.firstname', 'LIKE', "%{$search}%")
->orWhere('customers.surname', 'LIKE', "%{$search}%")
->orWhere('accounts.idnumber', 'LIKE', "%{$search}%")
->orderby('accounts.created_at', 'desc')
->paginate(10);
return view('admin.accounts.index')->with(compact('custacc'));
}
3
Answers
you need to clear route cache in your laravel application.
put following code to your route and all request will works fine.
now, when you create new route; you just have to run this route.
Laravel caching system also takes routes in consideration, to remove route cache in Laravel use the given below command:
You need to clear you rout cache every time you add new routes same with your view. With latest Laravel you can use
artisan optimize
in your command line or use the Route configuration.