Defining routes in api.php and web.php with same name - laravel

I have a route in my api.php file
Route::get('category/{id}/subcategory','SubcategoryController#categoryFinder')->name('cat_to_sub.find');
This route worked fine until i added another route in the web.php file
Route::get('category/{id}/subcategory',function(){return view('subcategories');});
And then when i run php artisan route:list
The URI api/category/{id}/subcategory has no name and i referenced that name all over my files and its throwing all these errors saying route cat_to_sub.find not defined
But when i remove the route in the web.php file everything works.
So whats causing this errors and is there another way to do it?

Related

Route [product.status] not defined

Route [product.status] not defined. (View: /home/zubair/htdocs/et-solves/cms/resources/views/cms/pages/home/home.blade.php)
please see error https://flareapp.io/share/4m4qvWPM
Route
Route::patch('/pages/product/status', 'HomeController#Status')->name('product.status');
I think so you are using prefix in your route group.
php artisan route:list --path=status
and check your route.

Laravel Route exist in artisan route:list but not in route files

When I am checking php artisan route:list, the route which i want to redirect is listed there.
for ex: admins.dashboard.panel
but I didn't found any related route in route code files.
And I have code in my LoginController as
return redirect()->route('admins.dashboard.panel');
which is redirecting to login page again.

Laravel 5.4 php artisan route:list showing incorrect data after a route:clear

I have the following issue. I am running laravel 5.4 and have a problem with my routes, when I navigate to my '/about-me' of my predefined routes I get the error:
1/1 NotFoundHttpException in RouteCollection.php line 179:
However the route is defined as shows here:
Route::get('about-me', function () {
return view('about-me');
});
On my view the link is pointing to that route as shown:
About Me
I have cleared my cached routes in SSH using the command:
php artisan route:clear
When I list my routes using the command:
`php artisan route:list`
I see an old version of my routes file. So this is the problem, however whatever I try they are not updating. I have cleared the cache locally and within laravel and still the old file file is showing when I type the route:list command.
I believe the code is all correct, however the new updated route file which contains the defined route for about-me is not being used. I have attached an image of the updated routes file on the server also.
Here is a link to the screenshot. Screenshot of route file on server
Thanks
In Laravel 5.4 (or in earlier version, I'm not sure) routes has been moved to the separate folder in app/routes/web.php (as you can see here: https://github.com/laravel/laravel).
You can find routes registration in app/Providers/RouteServiceProvider.php (https://github.com/laravel/laravel/blob/master/app/Providers/RouteServiceProvider.php#L52)

Laravel 5.1 NotFoundHttpException in RouteCollection.php line 161

I have an error which you can see in this picture, and I don't know how to fix it. I am using Laravel 5.1.
Error:
Sorry, the page you are looking for could not be found.
NotFoundHttpException in RouteCollection.php line 161
Either make your route something like in your Routes.php file from App\Http folder
Route::get('/laravel/alert/',function(){
//statement here
});
or change your page url to localhost/alert
Hope it will help you.
happyCoding
Assuming you Apache configuration is already pointed to your public folder in your project folder as DocumentRoot, it should able to work by accessing this route:
localhost/alert
I noted you use localhost/laravel/alert which looks wrong because you set your route to be /alert not laravel/alert
If you are not sure this is Apache or Laravel issue, run php artisan serve on the project folder and access the routes with this address, localhost:8000/alert

Laravel 5 - NotFoundHttpException

Here's my routes.php:
<?php
Route::get('/', 'StaticPagesController#index');
Route::get('about', 'StaticPagesController#about');
Route::get('contact', 'StaticPagesController#contact');
Route::get('signup', 'StaticPagesController#signup');
Route::get('login', 'StaticPagesController#login');
Route::post('login', 'LoginController#index');
i'm running my site locally via php artisan serve
d:\xampp\htdocs\some-website>php artisan serve
Laravel development server started on http://localhost:8000/
everything works fine. i can access each page (about, contact, signup, login) with no errors.
however, when i use XAMPP, i can only visit the index page:
localhost/some-website/public
i get a NotFoundHttpException in RouteCollection.php line 143 whenever i visit one of the following:
localhost/some-website/public/about
localhost/some-website/public/contact
localhost/some-website/public/signup
localhost/some-website/public/login
EDIT:
i tried editing my routes.php file to:
<?php
Route::get('/', 'StaticPagesController#index');
Route::get('/about', 'StaticPagesController#about');
Route::get('/contact', 'StaticPagesController#contact');
Route::get('/signup', 'StaticPagesController#signup');
Route::get('/login', 'StaticPagesController#login');
Route::post('/login', 'LoginController#index');
but no luck.
so it turns out my problem was with the project's folder name. i had it in CamelCase notation. changing it to lowercase got things sorted out.
shoutout to those who helped!

Resources