#laravel11 #laravel_tutorial #laravel_api Hi All, Sorry! I used error code 401 for validation. The code is wrong. Validation error code - 422 Unauthorized error code - 401 please change it while coding
Пікірлер: 17
@MakeeJkee10 сағат бұрын
I even went to like it, it’s just my salvation, there is a bug in laravel 11 ->validate and this video saved me😍
@Foxine15 күн бұрын
Thank you so much for this class! Thanks a lot! God bless you! Thank you!
@andreyp.5389Ай бұрын
Thanks a lot. Will fit for any level of developer :) I'm using laravel for 5-7 years but older versions mostly. I was surprised that 11th doesn't have scaffolded auth routes like it did before. From what I remember, previously you could just "php artisan make:auth" to have all needed auth routes
@suriyayashАй бұрын
nice one
@tintrinh6266Ай бұрын
How appreciate I have! That's great, thank you so much.
@arsyadfinan9189Күн бұрын
why when i try bearer is false not giving response unauthorized, but back to login route?
@pacogarcia22518 күн бұрын
Do you have the code uploaded to a repository in Github? Thanks for your effort.
@wildandvibeКүн бұрын
iam getting an error
@shubhamc4Ай бұрын
On validation fail. You should return 422 validation http code instead of 401 which is for unauthorized access.
@rubyvidhyaammu4984Ай бұрын
Thanks.... The error code detail was added in the description....
@DonLAtinopАй бұрын
Awesome video, thanks! btw , I am getting this in the profile link when the token is not right : Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined. in file Any idea how to fix it?
@rubyvidhyaammu4984Ай бұрын
The route is protected. Please add "Accept"=>"application/json" in Postman - Headers parameter. It will show: { "message": "Unauthenticated." } Laravel will check the configuration for "Accept", it will return the web page or html if no value is set at "Accept" by default.
@molefinance6826Ай бұрын
@@rubyvidhyaammu4984 but since this is in the api routes, can't we automatically get this behaviour without the necessity to send the Accept type? This would prevent the error on this endpoint.
@jenneracostadiazАй бұрын
Perffect 💖, one question please, in my intelephense return: Undefined method 'tokens'.intelephense(P1013) have you been able to resolve it?
@rubyvidhyaammu4984Ай бұрын
You need to check your return type. You'll find the warnings go away if you wrote something like this. Please try this in function.... $user = Auth::user(); if ($user instanceof \App\Models\User) { // Hinting here for $user will be specific to the User object return $user->createToken("API TOKEN")->plainTextToken; } else { // Handle Error. Not logged in or guard did not return a User object. }
@user-oi5qj1hg1l5 күн бұрын
@@rubyvidhyaammu4984 Hello, this worked for me. Is this a normal solution? public function logout(Request $request) { $request->user()->tokens()->delete(); return response()->json([ 'status' => true, 'message'=> 'User logged out', 'data' => [], ]); }