Category : laravel-routing

i have 2 routes, one for the admin and other posts, but they are conflicting, since in the Posts routes i could have another slug that is the category. Example: Route::get(‘{category?}/{slug}’, [AppHttpControllersSitePostController::class, ‘show’]); Route::prefix(‘admin’)->group(function () { Route::get(‘/login’, ‘[email protected]’)->name(‘login’);… How can i resolve it without adding other prefix to the Post or Admin? I see in ..

Read more

I am trying to have same routes for both, api and web endpoints, so that the code is easier to maintain and because both will use basically same URLs with same Controllers. Controllers are already written to return a proper response, so if request comes from API, it will return JSON and if from browser, ..

Read more

I’m trying to hit a route that needs to support multiple scopes for auth. It currently requires a scope called manage-clicks-creatives, but I would like to also allow manage-all-clicks-creatives. The Laravel docs seem to indicate that this is possible: The scope middleware may be assigned to a route to verify that the incoming request’s access token has at ..

Read more

<ul class="nav-list"> @if (Route::has(‘login’)) @auth @if (Auth::user()->role === 1) <li><a href="">{{ Auth::user()->name }}</a></li> <li><a href="{{ route(‘dashboard.index’) }}">Dashboard</a></li> <li><a href="{{ route(‘logout’) }}" onclick="event.preventDefault(); document.getElementById(‘logout-form’).submit();">Logout</a> </li> <form id="logout-form" action="{{ route(‘logout’) }}" method="POST"> @csrf </form> @else <li><a href="">{{ Auth::user()->name }}</a></li> <li><a href="{{ route(‘logout’) }}" onclick="event.preventDefault(); document.getElementById(‘logout-form’).submit();">Logout</a> </li> <form id="logout-form" action="{{ route(‘logout’) }}" method="POST"> @csrf </form> @endif @else <li><a ..

Read more

well i’ve made fully dynamic routes on laravel for friendly url’s reasons, something like this: Route::get(‘/{first}/{second?}/{third?}/{fourth?}/{fifth?}/{sixth?}/{seventh?}’,’[email protected]’); so, the user can access any tree data level from scratch. My problem is when some page has a link to any file on my system, like: mysite.com/storage/app/archives/9b1fe45fdf5db9203341b73931a9308a.pdf that is matching on the route with my dynamic routing, and ..

Read more

I work on Laravel 8 app with jquery 3/bootstrap 4.6 app in adminarea and on frontend part (vue 2.6/bootstrap 4.6/Axios) In admin area on invalid url resources/views/errors/404.blade.php was not triggered. I found that reason of was that in routes/web.php file in the end I have lines: Route::get(‘/{any}’, function () { return view(‘index’); })->where(‘any’, ‘.*’); If ..

Read more

I need to make my routes conditional, based on config: if (config(‘auth.allow_registration’)) {…. The above config param is set in the config file: //config/auth.php ‘allow_registration’ => false, It is all working fine, until I try to unit-test it public function test_registration_screen_can_be_rendered() { config()->set(‘auth.allow_registration’, true); $response = $this->get(‘/register’); $response->assertStatus(200); } The test case is failing. I ..

Read more

Is it possible to have a dynamic API route prefix whose value is based on the organization field from post request data? For instance, the post request data is: id: 1, name: ‘John Doe’, organization: ‘CISCO’ What I wanted in my route is: Route::prefix(‘CISCO’)->group(function() { Route::post(‘create’, [Controller::class, ‘create’]; }) And if it is not possible, ..

Read more

I have this route in my laravel app: Route::pattern(‘uuid’, ‘[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}’); Route::prefix(‘/profile’)->name(‘profile.’)->group(static function () { Route::get(‘/’, [ProfileController::class, ‘personalInfo’]) ->name(‘personal-info’); Route::get(‘/accounts’, [ProfileController::class, ‘bankAccountsList’]) ->name(‘accounts’); Route::get(‘/accounts/add’, [ProfileController::class, ‘bankAccountAddOrEdit’]) ->name(‘accounts.add’); Route::get(‘/accounts/{uuid}’, [ProfileController::class, ‘bankAccountAddOrEdit’]) ->name(‘accounts.edit’); Route::get(‘/password’, [ProfileController::class, ‘personalInfo’]) ->name(‘password’); }); Route::prefix(‘/real-estates’)->name(‘real-estates.’)->group(static function () { Route::get(‘/’, [RealEstatesController::class, ‘index’]) ->name(‘index’); Route::get(‘/{real_estate:uuid}’, [RealEstatesController::class, ‘details’]) ->name(‘details’); }); I use a global scope in my ..

Read more

These are the attributes I want to reference other tables $table->integer(‘carid’)->references(‘id’)->on(‘cars’) ->onDelete(‘cascade’); $table->integer(‘userid’)->references(‘id’)->on(‘users’) ->onDelete(‘cascade’); On phpmyadmin This is how my php Admin looks I want to reference these attributes as foreign key where I am wrong? Sourc..

Read more

I have and edit anchor tag corresponding to my entry on my webpage. So when I click on edit link. I get unique id attached to my URI http://127.0.0.1:8000/cars/edit/3 My href looks like this <a href="/cars/edit/{{$car->id}}" > And my corresponding web.php looks like this Route::get(‘/cars/edit/{{ $cars->id }}/’,function (Request $request, $id) And I want to use ..

Read more

I am currently on http://127.0.0.1:8000/cars/ I have a link that has to route me to http://127.0.0.1:8000/cars/create I used this in my code <a href="cars/create" </a> In my web.php I have following route Route::get(‘cars/create’,function () { return view(‘carsops.create’); }); When I click on link I am redirected to http://127.0.0.1:8000/cars/cars/create Instead of http://127.0.0.1:8000/cars/create What is the error ..

Read more

I want to create a route using Laravel 8 that will allow for a number of multiple and optional parameters. For example, if this route was displaying a list of people, it could be something like any of the following: /people /people/age/24 /people/hair/brown/age/30 /people/status/4 Or if it’s easier something like this: /people /people/age-24 /people/hair-brown/age-30 /people/status-4 ..

Read more

I created a resource controller. The problem is when I code a route in my view, the browser displays Route [course] not defined. I run the php artisan route:list command and I realize that the route does not exist in the route list. The controller method public function index() { $courses = Course::where(‘user_id’, Auth::user()->id)->paginate(10); return ..

Read more

in the given picture which i am taking reference if route to login or register controller is working fine but in this scenario i am making my own app if i route in same method not working IlluminateContractsContainerBindingResolutionException: Target class [Productcontroller] does not exist. in file C:xampphtdocslaravelblogvendorlaravelframeworksrcIlluminateContainerContainer.php on line 875 this error pops up why? ..

Read more

I have following route that expect locale in prefix Route::group([‘prefix’ => ‘{locale}/admin’, ‘where’ => [‘locale’ => ‘[a-zA-Z]{2}’], ‘middleware’ => ‘setlocale’], function() { Route::resource(‘/profile’, ‘AdminProfileController’, [‘except’ => [‘edit’, ‘create’, ‘destroy’, ‘show’, ‘store’]]); }); The final route supposed to be like this: www.example.com/en/admin/profile and www.example.com/en/admin/profile/1 while I can get index route www.example.com/en/admin/profile, but I cannot get update ..

Read more

I’m tenanting to develop a multi-tenant application in laravel 8. The connection is made to the tenant’s DB according to the ‘tenant’ parameter in the group in web.php. However, when I add Auth:routes() the following error appears: Missing required parameter for [Route: register] [URI: register] [Missing parameter: tenant] it’s my web.php route file: Route::group([‘domain’ => ..

Read more

I’m pretty confused about how ROUTE works in these cases. I have defined such a combination of routes: Route::apiResource(‘users’, ‘UserController’); Route::get(‘users/{user}/tasks’, ‘[email protected]’); And everything is fine. No issue. But I did the same for the other Model: Route::apiResource(‘tasks’, ‘TaskController’); Route::get(‘tasks/calendar’, ‘[email protected]’); And for this combination I got the NotFoundHttpException :/ { "message": "No query results ..

Read more

Service Provider <?php namespace MyPackageFaq; use httpExceptionRuntimeException; use IlluminateSupportServiceProvider; class FaqServiceProvider extends ServiceProvider { /** * Perform post-registration booting of services. * * @return void */ public function boot(): void { // set paths using realpath $src = realpath(__DIR__."/../src/"); $paths = [ ‘views’ => realpath($src.’/Http/resources/views’), ‘migrations’ => realpath(__DIR__.’/../database/migrations’), ‘routes’ => realpath($src.’/Http/routes/web.php’), ‘public’ => realpath( __DIR__.’/../public’) ..

Read more

Working with laravel 8 app started by other developer, I can not show file /resources/views/errors/404.blade.php(I have this file) when invalid url like http://127.0.0.1:8000/app_admin/platforms/2/editINVALID URL I got empty page with 200 Status Code returned in routes/web.php I see : <?php use IlluminateSupportFacadesRoute; … /* ========= For Adminside ========= */ Route::group(array(‘middleware’ => ‘auth_admin’, ‘prefix’ => ‘app_admin’), function() ..

Read more