I’m building an API to support an external application. I have added several routes to it with no problem, but suddenly, when I add a new route (acars/delay), I get a 404 error when trying to hit http://myurl.dev/api/acars/delay with a POST request. Here is my api.php file: Route::post(‘acars/deactivate’, ‘[email protected]’); Route::post(‘acars/ofp’, ‘[email protected]’); Route::post(‘acars/create’, ‘[email protected]’); Route::post(‘acars/pirep’, ‘[email protected]’); ..
Category : laravel-routing
Considering this route in web.php: Route::middleware(‘auth:sanctum’)->get(‘/test’, [TestConnections::class, ‘test’]);, Sanctum rejects it if the token is invalid (it is the case if it expired, or a bad token is given, an empty one, etc.). When Sanctum rejects a route, Guard.php‘s __invoke method returns return; so Laravel tries to reach the route "login". Indeed, Laravel shows this ..
In web.php, I have set this route: Route::middleware(‘auth:sanctum,expiration:1’)->get(‘/test’, [TestConnections::class, ‘test’]);. The middleware Sanctum’s Guard.php (https://github.com/laravel/sanctum/blob/2.x/src/Guard.php) has indeed a constructor that accepts the expiration as a parameter. I’ve expected that setting this expiration in the route’s middleware declaration was possible but my var_dump($expiration) that I’ve set in the constructor returns NULL, not 1. So this way ..
My problem is to redirect a user if they try to access a page with the request method not defined in the ‘web’ route. Currently this throws a SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException error: The GET method is not supported for this route. Supported methods: POST. Sourc..
I’m using Laravel 8 and I have this situation. Only users with the owner role can update their employees. I have one table for both owners, managers and employees and it is structured like this. | id | ——— | company_id | ———– | role_id | ———— | other_fields | I know how to give ..
I’m using Laravel 8, and I have this situation. Only users with the owner role can update their employees. I have one table for both owners, managers, and employees, and its structure is like the following. id company_id role_id other_fields I know how to give the owner or manager the authorization to modify employee data ..
I have a route group with this structure: Route::prefix(‘admin/{w_id}’)->middleware([‘auth’])->as(‘weblog.’)->group(function () { Route::get(‘/dashboard’, [HomePageController::class, ‘index’])->name(‘dashboard’); Route::resource(‘/blogcategory’, CategoryController::class); }); On dashboard route I have w_id in url and when I want to redirect user to blogcategory route (from anywhere) I need pass w_id manully in route helper class, I need some thing to set in globally from ..
For some reason the default route does not work (just "/admin") Route::prefix(‘admin’)->name(‘admin.’)->group(function () { Route::get(‘/’, ‘[email protected]’)->name(‘index’); //jcyjdyst yfcnhjryb cnhfybw Route::get(‘/main’, ‘[email protected]’)->name(‘main’); //jcyjdyst yfcnhjryb cnhfybw }); Route list: admin | admin.index | [email protected] | web | Sourc..
So in my service provider I bind the event model in the route: Route::model(‘event’, Event::class); Then I create this route: Route::view(‘/events/{event}/overview’, ‘cp.event-overview’) In this view I call a balde component that look like this: class EventHeader extends Component{ public $event; public function __construct(Event $event) { $this->event = $event; dd($event); } This returns an empty model ..
I have defined this route in the web.php route file: Route::get(‘/middleware_test_user_project_change/{pro_id}/{projet_id}’, function ($pro_id, $projet_id) { return ‘test’; })->middleware(‘user.project.change’); I have defined this handle function in my middleware (which I’ve added into the kernel with the following entry: ‘user.project.change’ => AppHttpMiddlewareCheckUserProposition::class): <?php namespace AppHttpMiddleware; use Closure; use IlluminateHttpRequest; use AppModelsUser; class CheckUserProposition { /** * Handle ..
I have created two apis one for college students and one for normal users. Normal users api is working fine but college api is not working properly. Can anyone help me fixing this error. What changes should I do ? Controller Codes for both are given below : Routes for both api Route::get(‘/get-user-enrollments/{offset?}’,’[email protected]’); Route::get(‘/get-college-enrollments/{offset?}’,’[email protected]’); Subject ..
I want to implement a dynamic way of the go-back button in my Laravel project. So I have this button: <a href="WHAT TO DO HERE"> <div class="go-back"> <div class="go-back-inside"> <h6 class="text">Go Back</h6> </div> </div> </a> Which I have included on every page, what I want to do is to have one button that is included ..
I’m working on a multi-language website where the URL’s contain localized strings. For instance: https://site/en/members/john-doe https://site/nl/leden/john-doe (and so for every language) In web.php I prefixed my routes. Via middleware I set the current language (retrieved from the first url-segment). This works fine for everything (both in controllers and in blade)… except for the urls generated ..
I’m getting this error: Expected status code 200 but received 404. Failed asserting that 200 is identical to 404. When I try to call it from my Unit Test: <?php namespace TestsUnit; use AppModelsProject; use TestsTestCase; class ExampleTest extends TestCase { public function testTakePlace() { $project = Project::factory()->make(); $response = $this->getJson(‘controllerUserProject_takePlace’, [ ‘project_id’ => $project->id, ..
I am using Laravel 6 and want to change the structure of some of my routes in the web.php file. When registering the following route like this: Route::view(‘/my-article’, ‘articles.my-article’)->name(‘my-article’); everything works as it should. But when changing the URL like this, adding /articles: Route::view(‘/articles/my-article’, ‘articles.my-article’)->name(‘my-article’); Suddenly no CSS is applied anymore. No Bootstrap, Fontawesome or ..
I am using Laravel 6 and want to change the structure of some of my routes. When registering the following route like this: Route::view(‘/my-article’, ‘articles.my-article’)->name(‘my-article’); everything works as it should. But when changing the URL like this, adding /articles: Route::view(‘/articles/my-article’, ‘articles.my-article’)->name(‘my-article’); Suddenly no CSS is applied anymore. No Bootstrap and no own stylesheet. JS script ..
I want to apply middleware on create route of resource controller but confused how to set middleware. Normally we can add middleware like this Route::get(‘api/users/{user}’, function (AppModelsUser $user) { return $user->email; })->middleware(‘name’); but when we have a resource controller so how could I apply middleware on single route of resource controller. Route::resource(‘front-pages’,’AdminFrontPagesController’); Sourc..
I am using laravel 8 with jetstream I want to know that how can I direct different users like admin or user to different routes? RouteServiceProvider has Public const Home = ”; but it only direct to a one route Sourc..
My route: Route::get(‘/{type?}/{filter?}’, [IndexController::class, ‘index’]); Is there a way, like form requests, where I can check that $type and $filter are specific values, for example $filter is equal to new or perhaps trending? I’ve considered just specifying the finite number of options as routes themselves: Route::get(‘/books/new’, [IndexController::class, ‘index’]); But I am then unable to get ..
What I have is an existing laravel application with blades , laravel routes and a few vue components. So I don’t want to replace the existing routes with vue router. What I want is to add additional routes without disturbing the existing laravel routes. For an example I have a category which already is using ..

I’m trying to get the id of the selected subscription and pass it to the controller, but for some reason when I dd() or print_r() the id in the controller, it returns the same id regardless of which subscription I click. Regardless if i click the first ‘+’ button or the second one it always ..
I have created a theme system and I am trying to make the theme’s route file pull pages from the database and assign a route to it, below is my theme route file. The issue I am having is an Undefined variable: theme from my ThemeSettings::all model request. Route.php (In theme) <?php use IlluminateSupportFacadesRoute; use ..
i created a website, i modified all the default direction of the blade laravel by my direction of my blade, but there is another direction i don’t know where i can modify it, it is when i enter login and password it authenticate with success but when I right click the mouse and I click ..
I’m setting up a delete route in Laravel 8.6.0 like this: api.php Route::delete(‘code-rule/{id}’, ‘[email protected]’); CodeRuleController.php /** * Remove the specified resource from storage. * * @param AppModelsCodeRule $codeRule * @return IlluminateHttpResponse */ public function destroy($id) { return response()->json(CodeRule::where(‘id’, $id)->first()->destroy()); } Now when I try a delete request in postman to the url localhost:8080/api/v1/code-rule/13/ I get ..
my question is if it is possible to pass data into the RouteServiceProvider.php file from the database with or without the controller. If so, could you tell me if my code below is correct. What I am trying to pass into my RouteServiceProvider is a theme location to make theme support cleaner and easier to ..