Questions tagged [laravel-routing]
Routing in Laravel Framework's MVC implementation. Laravel is a free, open source PHP web application framework, and it is released under the MIT license.
2,218
questions
0
votes
2
answers
97
views
Laravel 8 prefix on route not working when placed and url works with prefix if its not on code
I have a routes folder admin.php, with following intended code
Route::prefix('admin')->group(function(){
Route::get('/new/dashboard',[SuperAdminController::class,'dashboard']);
Route::get('/new/...
0
votes
1
answer
47
views
Custom Request class for validation gives 405 Method Not Allowed Laravel 10
I am trying to store data using store method and using VendorStoreRequest class for validation. However, I am getting : 405 Method Not Allowed error. When I change to normal Illuminate Request it ...
0
votes
1
answer
60
views
Laravel auth::sanctum middleware not working for API routes
I am getting the error InvalidArgumentException: Auth guard [auth] is not defined. with the below given code.I understood this error is because I have added auth in the guards array of config/sanctum....
0
votes
0
answers
69
views
Skip the route parameter from being passed to the closure function in Laravel
Is it possible to skip the route parameter from being passed to the closure function in Laravel 10.x? For example, do not pass the locale to the closure function.
Route::get('/{locale}/{parem1}/{...
0
votes
0
answers
20
views
How to connect module routes to routes in Laravel 10
I was facing an issue in the view file of laravel 10 where I was not connected with the module view to the main index.blade.php
I was add like these @include("dailyprocess::dailyproces", ['...
0
votes
0
answers
38
views
Laravel routing issue with implicit binding only on staging server
I've come across a very unusual bug that happens only on our staging server.
Here is part of my routes.php file
Route::post('posts/add', [PostController::class, 'batchAdd'])->name('posts.batch-add')...
4
votes
2
answers
96
views
Laravel route model binding for model with UUID does not instantiate the model
I've run out of ideas, so I thought I'll ask around. Here's my code:
# app/Map/MapServiceProvider.php
class MapServiceProvider extends ServiceProvider
{
/**
* Bootstrap any package services.
...
0
votes
1
answer
28
views
Laravel - redirect to route with id after successfull ajax
I am trying to figure this out. I have backend in laravel and i am returning id of new created client. How can i use this param in js redirect? This is my best try but i am getting into this url: ...
0
votes
1
answer
17
views
add extra 'admin' prefix in admin routes in laravel 8
I have created some routes in Laravel using Route::methods and also resources but some admin and non-admin routes add extra 'admin' prefix in routes.
So when I am calling the routes it does not work ...
0
votes
1
answer
37
views
Can I get same data using POST rote that I got using GET route
I have two routes in my Web.php,
Route::get('/employees', [ApiController::class, 'employees'])->name('employees');
Route::post('/employeesPost', [ApiController::class, 'employees'])->name('...
-1
votes
1
answer
41
views
Why am I getting get method not supported error(supported method : post) even though I use post method?
I am trying to build a user and client page with laravel I created a page that can be used to create users now I want to create a page just like that when I click those users but I keep on getting ...
0
votes
0
answers
57
views
Use Macroable or allowing somehow to add custom attributes to RouteRegistrar
I'm doing this:
\Illuminate\Routing\Route::macro('description', function (string $description): AppServiceProvider|\Illuminate\Routing\Route {
$this->action['description'] = isset($this-...
0
votes
0
answers
43
views
Laravel ReflectionException 'Class does not exist' error though everything is perfect
In my laravel api, I have this folder structure:
And my code for routes/api.php here
Route::group(['prefix' => 'v1/admin', 'as' => 'api.v1.admin.', 'namespace' => 'Api\V1\Admin'], function ()...
0
votes
3
answers
91
views
Route returning 404 NOT FOUND for /about-us in Laravel. How to resolve it?
PHP Version - 8.2.4
Laravel 10
I am facing an issue with one of the routes in my Laravel application. I have defined a route for the '/about-us' URL, but whenever I try to access it, I get a 404 NOT ...
0
votes
1
answer
54
views
What does to_route('route_name') mean in Laravel?
I saw this in this tutorial:
return to_route('route_name');
Does to_route('route_name') mean the same as redirect()->route('route_name)?
I tried finding an explanation in the Laravel docs, but ...
0
votes
2
answers
122
views
Automatic Module-Based Route Generation in Laravel Using Directories: Is It a Good Approach?
I have been working on a Laravel project where I needed to organize my codebase using modules. To achieve this, I created separate directories for each module under the app/Modules folder. One ...
0
votes
1
answer
238
views
Laravel Dynamic Route names depends on optional route param
In Laravel 10, I have routes that are structured like the following:
Route::group(['middleware' => ['permission:edit-settings']], function () {
$module_name = 'settings';
$controller_name = ...
0
votes
1
answer
44
views
How to define a route which chooses to right Controller on the fly /{slug}
I am currently facing the challenge, that I have the same route pattern for two Controllers.
To make it easier, let's say we have a BlogController and a PageController. Both controllers have the same ...
0
votes
0
answers
59
views
Laravel correct URL is returning incorrect content
in Laravel, I have made a project to handle supervisors to supervisor their students PG or final year project,
here is a simple explanation of what the project is about,
every use can have many roles, ...
0
votes
1
answer
112
views
Capture domain in Laravel routes file as url variable
I have a problem capturing the domain in the routes file.
When a route is written like this:
Route::domain('mydomain.com')
->get('/', function () {
return "It works";
});
...
0
votes
0
answers
57
views
how to set resource route using controller case by ID and on the controller get the id
without resource, I can use like this is work:
use App/Http/Controller/Aaa/XxxController as AaaXxxController;
use App/Http/Controller/Bbb/XxxController as BbbXxxController;
Route::get( "/aaa"...
0
votes
1
answer
391
views
Laravel: Login doesn't redirect to home
I am having issues logging in using Laravel. Every time a user logs in, it redirects them to the post route (a blank page) instead of home, which is the intended route. Even when I login with the ...
-1
votes
2
answers
213
views
Laravel 5.8: How to add a custom anonymous route to the Laravel's core file
I have a Laravel 5.8 application and I need to add a custom anonymous route to the Laravel's core file which is Router.php and located in this directory:
/vendor/laravel/framework/src/Illuminate/...
-1
votes
2
answers
72
views
What is the faster way to load callback from class in laravel route
1. Route::get('list', [App\Http\Controllers\Driver\DocumentController::class,'list']);
2. Route::get('list', ['Driver\DocumentController@list']);
What is the faster way to load callback from class ...
-2
votes
2
answers
63
views
Laravel Namespace Resource Controller Routing
I was working on a laravel project. The following is the code of my UserController:
<?php
namespace App\Http\Controllers\Backend\Admin\Users;
use App\Models\User;
use Illuminate\Http\Request;
use ...
-1
votes
2
answers
431
views
Missing method in laravel 10 doesn't work?
I'm trying to treat this 404 erro return and I can't do it using the apiResources and Missing method.
For example, I'm doing this:
And whenever it give me a 404 page web error.
Tks!
Route::...
0
votes
1
answer
234
views
Laravel Fortify verification.notice route not defined
I am trying to use Laravel Fortify for authentication. All routes work fine except for email verification.
I have done everything according to docs as far as I understand:
Impemented Illuminate\...
0
votes
1
answer
1k
views
Laravel call internal API from controller using post and passing basic auth authorization to request
I am calling internal API route from controller but unable set headers using laravel 8
$request = Request::create('/api/login/', 'POST',['id' => '1']);
$request->headers->set('Authorization','...
0
votes
4
answers
1k
views
Laravel 9 Route [login] not defined
api.php file:-
<?php
use App\Http\Controllers\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|---------------------------------------------------------------...
0
votes
2
answers
542
views
Missing required parameter for [Route: xxxxx]
I am having this route setup on my laravel app which uses the FooController which uses an __invoke method
Route::get('/foos/{foo:baz_param}', FooController::class)->name('foos');
I am also having ...
0
votes
1
answer
288
views
Allow special characters and symbols to be part of route parameter
I am trying to send a s3 link of an image to an image viewer, the link has special characters like ?, & and =, I want send the link to the route as a route parameter and can't find a way to make ...
1
vote
1
answer
767
views
Unable to get the actual remaining time from rate limiter
I've created a rate limiter for login which limits the request to n times per 10 minutes. If a request has reach the rate limit, I want to return a validation exception informing the remaining time ...
0
votes
1
answer
43
views
how to send ajax parameter as laravel route parameter?
I try to create eshop with laravel and ajax. I have product.blade.php file that I make cards with ajax. I wanna show every product detail in other page. so I need to pass element._id to my route.
this ...
0
votes
1
answer
98
views
Multidomain Laravel App with partially same codebase
I am trying to implement a app, which provides two different login types based on the domain the user enters from. After successful login, the user gets a standard role and all users share the same ...
0
votes
0
answers
29
views
Missing required parameter for [Route: puja_detail] [URI: puja_detail/{puja_slug}] [Missing parameter: puja_slug]
Missing required parameter for [Route: puja_detail] [URI: puja_detail/{puja_slug}] [Missing parameter: puja_slug].
View File- puja_slug }}" class="btn1 btn-outline-success btn-sm">Read More
Route- ...
0
votes
0
answers
30
views
issue in laravel hierarchy dynamic pages
i want to make a site that maybe has 3-4 levels or more for its pages
like:
example.com/level1/level2/level3 /.../level n
but when i use :
Route::get(/{page?slug} ,[controller::show]})
it returns ...
1
vote
1
answer
189
views
Adding Namespace To Route Service Provider NOT WORKING
I'm working with Laravel 9 and I want to use Laravel Old Style of routing.
So inside RouteServiceProvider.php, I added this:
protected $namespace = 'App\Http\Controllers';
Then for the web routes:
...
-2
votes
1
answer
48
views
Includin many models in the routes `web.php` file practice
I have many routes, and for a single page (my homepage) I need to sample almost all of my models. I do it like that:
use App\Models\Aa;
use App\Models\Bb;
use App\Models\Cc;
// and so on ...
Route::...
0
votes
1
answer
359
views
Laravel 9 multiple middleware in route
I have this route, that should work for both middlewares
Route::middleware(['company', 'consultant'])->group(function () {
Route::resource('/tasks', TaskController::class);
});
If I do
Route::...
1
vote
1
answer
231
views
Laravel: how to write test for route Macro, Middleware and Model binding
I build a simple way to identify tenant with subdomain, ex: user1.example.com, and tenant will be user1. On the other hand, if user1 does not exist, the user1.example.com will response 404.
I define a ...
0
votes
1
answer
38
views
Unable to load 45k root url in the laravel web.php
My client have 7896 pages on previous website
URL of older website like: www.domain.com/{url}
Now client want to make new website but he need same url structure as older one (www.domain.com/{url})
...
0
votes
0
answers
25
views
What is the reason for routes defined with any(), match(), redirect() methods to be defined below then routes with methods get(), post() etc.?
I came across below paragraph in laravel 8 documentation at https://laravel.com/docs/8.x/routing. Can you guys make me understand it with a reason; why it s so?
When defining multiple routes that ...
0
votes
2
answers
51
views
How to set custom route name before main route in Laravel?
I want to add username before each route..
ex:
sam/productDashboard
james/productDashboard
note - Username is getting from session.
i tried like this. it doesn't work
Route::get( session()->get('...
-1
votes
1
answer
140
views
Route Model binding in Laravel
I have a Laravel app and a model Category. It has a relation to itself called parent
Category.php
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_uuid', 'uuid'...
-3
votes
2
answers
345
views
PUT and DELETE route is not showing in laravel route list on apiResource [closed]
I added apiResource routes in my api.php file. Although it shows all the resourceful routes for product/category, it is not showing the routes for PUT and DELETE methods in the case of products routes....
0
votes
1
answer
27
views
How to solve route nullable peremeter problem
here is my route:
Route::get('statement/{month?}/{userid?}', 'UserController@statement');
The problem is there $month or $user_id may or not may be. If $user_id found and $month not found so the $...
0
votes
2
answers
579
views
What is the correct method to pass parameter to Laravel controller for filtering data?
This is my code of route for getting data from Laravel backend.
Route::get('/get/card',[CardController::class,'getCardList'])->name('card.list');
I call it like below,
http://127.0.0.1:8000/get/...
0
votes
1
answer
116
views
redirect to admin route when admin not loged in
I wanted to check if the user logged in and then accessed the dashboard route; otherwise redirected to the admin login page, But it always turned me to the admin page while I entered my email and ...
-1
votes
1
answer
65
views
laravel nested controller with 3 model
is possible to use 3 model in laravel nested controller?
this my route now:
...
'supplier' => SupplierController::class,
'supplier.item' => SupplierItemController::class,
...
i want to use 3 ...
0
votes
1
answer
265
views
How to fix route has error Laravel that showed me when I hovering the Route::has that show me a alert
How can I solve the problem shown in the image above (Route::has) Laravel?