Category : routes

I’m getting error 500 when I try visit a dynamic route. The parameter is optional and is working well when I avoid it. This is the code Route::get(‘/{slug?}’, function ($request = ”) { $code = empty($request)? ’47ZH2′ : $request; return view(‘home’, [‘code’ => $code]); })->where(‘slug’,’^([0-9A-Za-z-]+)?’); Even I tried without regex but is not working anyway. ..

Read more

I’m trying to use middlewares to protect Routes based . But I think I’m doing something wrong in the process. This is the Route I have and I want only the users that have administrador role to be able to enter it. Route::get(‘/gestionarMedicos’, [PersonaController::class,’mostrarMedicos’])->name(‘personaMostrarMedicos’)->middleware(‘auth’,’firstLogin’,’role:administrador’); This is my middleware (in the route its the one called ..

Read more

I’m trying to use middlewares to protect Routes based . But I think I’m doing something wrong in the process. This is the Route I have and I want only the users that have administrador role to be able to enter it. Route::get(‘/gestionarMedicos’, [PersonaController::class,’mostrarMedicos’])->name(‘personaMostrarMedicos’)->middleware(‘auth’,’firstLogin’,’role:administrador’); This is my middleware (in the route its the one called ..

Read more

I’m trying to use middlewares to protect Routes based on role. Im testing with this route to allow only the role administrador to be able to enter it. Route::get(‘/gestionarMedicos’, [PersonaController::class,’mostrarMedicos’])->name(‘personaMostrarMedicos’)->middleware(‘auth’,’firstLogin’,’role:administrador’); This is code of my middleware (in the route its the one called route) <?php namespace AppHttpMiddleware; use Closure; use IlluminateHttpRequest; class EnsureUserHasRole { /** ..

Read more

I’m trying to use a middleware to validate the roles and I’m using the example that is in Laravel documentation. <?php namespace AppHttpMiddleware; use Closure; use IlluminateHttpRequest; class EnsureUserHasRole { /** * Handle an incoming request. * * @param IlluminateHttpRequest $request * @param Closure $next * @return mixed */ public function handle(Request $request, Closure $next, ..

Read more

Is it possible to set a global language prefix to every url: Currently php artisan route:list –compact gives +———-+———————————-+-.. | Method | URI | Action.. +———-+———————————-+-.. | GET|HEAD | api/user | Closur.. | GET|HEAD | forgot-password | LaravelFortifyHtt… | POST | forgot-password | Lara.. | GET|HEAD | livewire/livewire.js | Livewire.. .. | GET|HEAD | login ..

Read more

I have a dashboard that shows 4 chart stats and an area chart. I know it’s impossible to use same URI in routes such as this: Route::get(‘dashboard’, [DashboardController::class, ‘createChartStats’]); Route::get(‘dashboard’, [DashboardController::class, ‘createChartMonthlyInvoicesAndSales’]); I haven’t created the createChartMonthlyInvoicesAndSales() method yet, but is there a way I can still use dashboard URI so I just can display ..

Read more

I am using laravel to have access to my database. I have used the command php artisan make:controller CategoriesController –resource in the terminal to create a class where I can access different methods in one route. The routing code for the class is: Route::apiResource("categories", CategoriesController::class);. With /categories I can get to the index() method (via ..

Read more

hide id from url https://wallpaperaccess.in/photo/162/download-wallpaper i want url like this https://wallpaperaccess.in/photo/download-wallpaper ImagesController.php public function show($id, $slug = null ) { $response = Images::findOrFail($id); $uri = $this->request->path(); if( str_slug( $response->title ) == ” ) { $slugUrl = ”; } else { $slugUrl = ‘/’.str_slug( $response->title ); } $url_image = ‘photo/’.$response->id.$slugUrl; //<<<– * Redirect the user real ..

Read more

I have the following component in my laravel/Vue application. When the user clicks on this button I want to send them to the privacy blade. (sample.site/privacy-policy) <template lang=""> <div class="verbatimGameLayout__footer"> <FeedbackButton label="Vie privée" :onClick="goToFeedback" /> <SaveButton label="sauvgarder" /> </div> </template> export default { components: { FeedbackButton }, methods: { goToFeedback() { window.location = "/privacy-policy"; } ..

Read more