#### Category : routes

I need to pass two variables from two different controllers to a view and display the different values from the array variables to two different html form’s select options in Laravel 8. But Laravel doesn’t seem to allow pass two differnt variable to a single view. How do I slove this? Please find the error ..

I haven’t changed anything to the 1st route. only added the form submission routes then the error occurred yet its pointing the the first route? The error points to line 17 with the following yet i cant understand why syntax error, unexpected token "::", expecting "," or ";" 17> Route::get(‘/’, function () { return view(‘welcome’); ..

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 Let’s say I have a controller called TeamsController. Controller has following method, that returns all teams user has access to. public function findAll(Request$request): JsonResponse { //… } Then I have bunch of other controllers with the same method. I would like to create a single route, that would work for all controllers, so I ..

I am using laravel to develop my project. In my controller I have Variable called $products and i’m passing that variable to the view , return view(‘products.index’)->with("products",$products); No any issue till here ! Now i want to pass same $products to the other view, <a href="{!! route(‘productsnew.index’) !!}"> Click Here </a> How can i pass .. Read more So im busy on my first laravel project. Now everything is coming along nice. However certain parts are really not going well, and any advice help would be appreciated. I have my main navbar that is defined and in my main.blade.php Now this main navbar shows up nice on all pages. However i also would .. Read more The route setting I have in my Laravel 8 app is the following: Route::match([‘post’], ‘/sample’, ‘[email protected]’); Now if I do through a GET request curl http://127.0.0.1/sample/ I will get a very big response with stack trace information back. This is really bad as I would like to hide the framework I am using to users .. Read more In Laravel I had a problem. And the output of a function that I defined in a class(Controller) is as follows in the browser: ====>>>> This page isn’t . workinglocalhost redirected you too many times. <<<<===== And does not define and direct me to Route. I expect to be transferred to this route after the .. Read more I installed passport and have a route in the api.php file. The web route works but the api routes always give me a 404 – Not Found in Postman. This is my route This is my UserController Function Sourc.. 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 i am creating a php project for myself and it is not on laravel, i install illuminate/database package on my project for using elequent and its work perfectly. now i want to use laravel routing system in my project but can not find any Instructions for this is there any way to use that? Source: .. Read more Is it possible to use Laravel routing in a Symfony application ? Thank you for response ! Sourc.. Read more i want to make a redirect panel and add some urls to it, if this urls are called(requested) it should redirect to new url before checking it in routes ->web.php file. i used a middleware for this and added the middleware to middlewares list in kernel but it doesn’t work for some urls, what is .. Read more I recently finished off my laravel app, however, I decided to change the name of the project, I’ve renamed the project in config/app.php from laravel-app: ‘name’ => env(‘APP_NAME’, ‘M-Tech’), and I also changed it in the .env file. APP_NAME=M-Tech However I also changed the folder names which the project is in from laravel-app to M-Tech-app .. Read more I have a new Laravel 8 application with one controller in the main folder and one route. Route::get(‘/’, ‘[email protected]’)->name(‘index’); It does not work without the full namespace in the route. But it is default. What should I do to remove the namespace from the route? Without the namespace it throws an error: Target class [DefaultController] .. Read more I am making a Quiz App. I want to show if the answer is wrong or correct in front of my question. I got the correct result but don’t know how to display result in front of my question. In my blade My Code is <form action="search" method="post" role="search"> @csrf @if(isset($users)) @foreach($users as$answer) <input ..

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 ..