Validate parameters in laravel

I have some doubts about validating parameters coming from a route. This is an example code, but I’m not sure if it’s 100% correct as a best practice. Regarding the various ids that are passed on the route, is it good practice to check that the id actually exists in the table? If so, should… Read More Validate parameters in laravel

Route [listadopresos] not defined IN laravel 8

I wanted to add a link to another page in a view, but I get the following error message enter image description here this is my web.php the route "listadopresos" doesn´t works use Illuminate\Support\Facades\Route; use App\Http\Controllers\CustomAuthController; Route::get(‘dashboard’, [CustomAuthController::class, ‘dashboard’]); Route::get(‘listadopresos’, [CustomAuthController::class, ‘listado’]); Route::get(‘login’, [CustomAuthController::class, ‘index’])->name(‘login’); Route::post(‘custom-login’, [CustomAuthController::class, ‘customLogin’])->name(‘login.custom’); Route::get(‘registration’, [CustomAuthController::class, ‘registration’])->name(‘register-user’); Route::post(‘custom-registration’, [CustomAuthController::class, ‘customRegistration’])->name(‘register.custom’); Route::get(‘signout’,… Read More Route [listadopresos] not defined IN laravel 8

How to pass a variable right through the routes

I get an error when I try passing the var in the routes like this <a href="{{route(‘canvas’,[‘size’=>1000])}}"> … </a> I pass the view like this public function canvas($size){ return view(‘main.canvas’)->with($size); } this is the route I use in web.php: Route::get(‘canvas’,[CustomAuthController::class,’canvas’])->name(‘canvas’); the error I get is this: Too few arguments to …\CustomAuthController::canvas(), 0 passed in …\Controller.php… Read More How to pass a variable right through the routes

How to pass multiple params to a HttpGet method inside of a C# ApiController?

I have this: public class RuleController : ApiController { private readonly IRuleManager _ruleManager; // GET: api/Rule/guid [HttpGet] public IHttpActionResult GetRule(Guid id) { var rules = _ruleManager.GetRulesById(id); return Ok(rules); } [HttpGet] public async Task<IHttpActionResult> GetRuleNew(string locale, string pno, string modelYear) { // do cool stuff with my params } } my route config: config.Routes.MapHttpRoute("DefaultApiWithId", "Api/{controller}/{id}", new… Read More How to pass multiple params to a HttpGet method inside of a C# ApiController?

Getting http://127.0.0.1:8000/route('welcome') instead of http://127.0.0.1:8000/ in laravel 9

I’ve come across a peculiar bug in a laravel project of mine, In my web.php I have a named route ‘welcome’ : Route::get(‘/’, function () { return view(‘welcome’); })->name(‘welcome’); This route contain my index page in which there’s a navigation component. Through an AppServiceProvider I’m passing data to the navigation component The data im passing… Read More Getting http://127.0.0.1:8000/route('welcome') instead of http://127.0.0.1:8000/ in laravel 9

Pass multiple data with redirect()->route() in Laravel 9

I have this route in web.php: Route::get(‘student/evaluation/{evaluation}’, [EvaluationController::class, ‘getEvaluationQuestions’])->middleware(‘auth’)->name(‘student.questionsevaluation’); And in my controller I have this condition, where $questionWasCompleted is boolean if($questionWasCompleted){ return redirect()->route(‘student.questionsevaluation’, $evaluation)->with(‘message’, ‘Question answered.’); } How can I pass the $questionWasCompleted parameter in this redirect()->route() ? >Solution : Pass a second with() method in your controller like this: return redirect()->route(‘student.questionsevaluation’, $evaluation) ->with(‘message’,… Read More Pass multiple data with redirect()->route() in Laravel 9

404 not found when navigate by route on symfony

When i navigate on route i can’t see my page web , i has just get 404 not found # config/routes/attributes.yaml controllers: resource: ../../src/Controller/ type: attribute kernel: resource: ../../src/Kernel.php type: attribute“` # Controller namespace App\Controller; use Symfony\Component\HttpFoundation\Response; class LuckyController { #[Route(‘/lucky/number’)] public function number(): Response { $number = random_int(0, 100); return $this->render(‘lucky/number.html.twig’, [ ‘number’ =>… Read More 404 not found when navigate by route on symfony

Login page won't render in React v18

I’m having a problem with my routes in React v.18. I cannot get a login page to render. Index.js const rootElement = document.getElementById(‘root’); const root = createRoot(rootElement); root.render( <React.StrictMode> <Router> <App/> </Router> </React.StrictMode> ); App.js export const App = () => ( <> <Routes> <Route path="/login" element={<Login />} /> <Route path="/register" element={<Register />} /> </Routes>… Read More Login page won't render in React v18

how to return a custom error message when someone is trying to access a protected group of routes in laravel 9

question: i have several routes in my API , grouped with middleware ‘sanctum’, like below: Route::group([‘middleware’ => [‘auth:sanctum’]],function() { Route::put(‘/products/{id}’,[ProductController::class,’update’]); Route::post(‘/products’,[ProductController::class,’store’]); Route::delete(‘/products/{id}’,[ProductController::class,’destroy’]); Route::post(‘/authlogout’,[AuthController::class,’authLogout’]); }); now i want to show a custom error message when someone is trying to access these routes without appropriate credentials, currently, when someone tries to access them, he/she would get something… Read More how to return a custom error message when someone is trying to access a protected group of routes in laravel 9