Laravel API Crash Course With Sanctum | Laravel Sanctum Full Tutorial | How to Build Laravel API

Поделиться
HTML-код
  • Опубликовано: 27 дек 2024

Комментарии • 312

  • @codewithdary
    @codewithdary  Год назад +7

    If you're looking to level up your Laravel skills? My new course "Mastering Laravel 10 Query Builder, Eloquent & Relationships" is the perfect opportunity: www.udemy.com/course/mastering-laravel-10-query-builder-eloquent-relationships/?referralCode=C784C3DB5B8925207FCB

    • @devopsdevelopoptions409
      @devopsdevelopoptions409 4 месяца назад

      and i want to say that the video was perfect for me as a beginner in apis

  • @joshmakar9161
    @joshmakar9161 11 месяцев назад +1

    This crash course not only explained the basics of using Sanctum but also included a ton of valuable information about configuring APIs, using ResourceControllers, implementing custom requests, and so much more. Very well done!

    • @codewithdary
      @codewithdary  11 месяцев назад

      Thank you so much, I appreciate your kind words Josh!

  • @sv2109
    @sv2109 Год назад +9

    Man, you have a real talent for explaining complex topics so that they seem very simple

  • @AstreonOfficial
    @AstreonOfficial 2 года назад +15

    When declaring resource routes that will be consumed by APIs, you will commonly want to exclude routes that present HTML templates such as create and edit. For convenience, you may use the apiResource method to automatically exclude these two routes. Like this: Route::apiResource('tasks', TasksController::class);

    • @codewithdary
      @codewithdary  2 года назад +4

      Wait I didn’t do that in this tutorial! I’m ashamed! you are completely right.

  • @jackreacher8632
    @jackreacher8632 7 месяцев назад

    Before I even finish this video let me say that your are an amazing professor. That tutorial is so fluent , explaining patiently concepts I was hardly trying to understand. Thank you very much from Burkina Faso.

  • @sb-dor
    @sb-dor Год назад +1

    thank you so much man, I've been working as a full-stack developer for a long time, and i didn't know some of that stuffs in laravel. push forward bro. greate video!

  • @AbderrahmanFodili
    @AbderrahmanFodili Год назад +2

    you are a lifesavour . I loved you content when I was still learning a year ago and I am even more thankful that you posted this video now that I got a job and I am asked to make an API. your methods are light years ahead of my put together garbage API . thank you good sir

    • @codewithdary
      @codewithdary  Год назад +2

      Thank you so much Abderraham! Tried my best making it easy for you. I've also got a video where I create a property listing API, might be useful for you too :)

  • @meetwithchuks8861
    @meetwithchuks8861 2 года назад +8

    I love your tutorials; clear and in-depth. This is the latest and the best. Many thanks.

  • @n3volja
    @n3volja Год назад +1

    I loved this! Thank you for making this.

  • @MrWorkman2010
    @MrWorkman2010 6 месяцев назад

    What!! I have successfully gone through this entire tutorial. Was very helpful.

  • @knockedbull7087
    @knockedbull7087 Год назад +1

    Very well explained with details, common mistakes and coding things step by step so we are not saturated. One of the best teacher i've watched so far. Thanks a lot for this tutorial

    • @codewithdary
      @codewithdary  Год назад

      Wow, your comment just made my day. Thank you so much :)

  • @madie2659
    @madie2659 2 года назад +1

    Best Laravel video with great explanations I have seen on RUclips.. Thank you sooo much for this video

  • @cryswerton-silva
    @cryswerton-silva Год назад +4

    Best video on Laravel Sanctum ever!!

  • @zoltanfodor1605
    @zoltanfodor1605 10 месяцев назад +1

    It was a good-quality video. Thanks a lot, Dary!

    • @codewithdary
      @codewithdary  10 месяцев назад

      Glad you liked it, Zoltan!

  • @kavehsarkhanlou8608
    @kavehsarkhanlou8608 2 года назад +4

    You are wrapping your credentials array in an extra array. Remove the extra array wrap in line 21 at 37:58

  • @EddieMao
    @EddieMao Год назад +1

    Wow, wonderful tutorial, Dary. Thank you so much.

  • @FelixLuk-g9l
    @FelixLuk-g9l Год назад +1

    Hi Dary, very good video. Just one small suggestion: pause for a second or two before you switch screen or program, so that your viewers get a chance to pause. Also, there is a small problem with the cli when the screen is paused, as YT's control overlaps on the last line, which happens to be what you are typing. So maybe using a ssh client to connect locally?

    • @codewithdary
      @codewithdary  Год назад

      Thank you for the feedback, it is truly appreciated! I will definitely implement your feedback.

  • @muhammadzohaibyunis5872
    @muhammadzohaibyunis5872 Год назад +1

    Hi @Dary can you kindly guide on routing 17:13 / 1:20:42 it says Target class [AuthController] does not exist. / tried the get too

    • @codewithdary
      @codewithdary  Год назад +1

      You most likely haven't added the AuthController inside the use statement (at the top) but tried to call it in the route!

  • @PacificDev
    @PacificDev Год назад +1

    Great video! Thanks 👊
    When validating a form request you actually don't need to call request->all() inside the validated() method. It doesn't need it. The validated method returns an array with the validated fields.

    • @codewithdary
      @codewithdary  Год назад +1

      That is correct! Don't know why I did that....

  • @ABEDALLAHGOZAH
    @ABEDALLAHGOZAH Год назад +2

    how you used auth->attempt() to verify the credentials and in the same time generate a token, that's not a good practise because the auth()->attempt apply the seesion based authentication so the server is created a session on it after using this method

    • @codewithdary
      @codewithdary  Год назад

      The auth()->attempt() method is used to verify the credentials and log in the user. However, it does not generate a token directly. Instead, after successfully logging in the user, the code creates a token using $user->createToken('API Token')->plainTextToken.

    • @ABEDALLAHGOZAH
      @ABEDALLAHGOZAH Год назад

      ​@@codewithdary Yes, I mean after a successful attempt to log in user using the auth()->attempt() method the server creates a session for this user and sends it back to the browser, and no benefits from using the token-based authentication because as I know that among need for the token is to make the server more free in memory

  • @LuiBorosu
    @LuiBorosu Год назад +1

    If there is anything that i want to complain about in this tutorial, you need to show us every namespace that you used inside your controller. not all of us who are trying to learn laravel knows how to automatically add them whenever you used a class that isnt inside of the controller originally. It confused the heck out of me. 6/10. man do what i just said and it will be instant 9/10. cuz its such bummer to suddenly getting an error when i literally do everything you did step by step.

    • @codewithdary
      @codewithdary  Год назад

      Namespaces are something you should learn in PHP, and not so much in Laravel. Let alone starting with Laravel Sanctum, which you shouldn't learn if you have no idea how namespaces work. I understand your concern, but I can't explain every single step over and over again, overwise people will start complaining about me repeating myself :)
      A part of being a developer is also making decisions on your own. You shouldn't just follow the tutor and expect to be a developer after a certain amount of hours.

  • @davidadewale8466
    @davidadewale8466 Год назад +2

    Thanks for the tutorial… I’m stucked here. I kept getting error (Error, class “Task” not found) when I tried to use tinker to generate task . Any assistance will be welcomed. Thanks

    • @codewithdary
      @codewithdary  Год назад +1

      This happens sometimes when composer has not loaded the classes correctly. The simplest solution is to add the entire path to it such as App\Models\Task

  • @felixowino3271
    @felixowino3271 2 года назад +3

    I get an error message in the postman SQLSTATE [42S22] column not found when i test login with a user who is not in the database, what could be the issue?

    • @ChBoss-fc2yj
      @ChBoss-fc2yj 2 года назад +9

      Hay Felix, try "if(!Auth::attempt($request->only('email','password'))) {" instead of "if(!Auth::attempt([$request->only('email','password')])) {"

    • @ThaRealIansanity
      @ThaRealIansanity 2 года назад

      @@ChBoss-fc2yj Thanks I'm always forgetting you can hover or ctrl+click on functions to see their definitions. It already returns an array 🙂

    • @mudso
      @mudso Год назад

      @@ChBoss-fc2yj GREAT THANKS! you saved my day, is that square bracket a laravel 9 or 10 thing?

  • @HarshSharma-xp7uf
    @HarshSharma-xp7uf Год назад +1

    Fantastic Tutorial Dary. I am a newbie to laravel and your videos are just fantastic. Thank you

    • @codewithdary
      @codewithdary  Год назад

      Thank you so much Harsh, truly appreciate your kind words.

  • @deathlotos522
    @deathlotos522 10 месяцев назад

    39:52 is the first argument of createToken method (i mean name here) somehow credential and affects generated token value or it doesnt matter at all?

  • @autoge13
    @autoge13 Год назад +1

    Why don't you use auth()->user() to get the current user instead of User::where('email',.....) after the Attempt? If the Attempt succeeds doesn't it mean that the auth() helper can be used as well?

    • @codewithdary
      @codewithdary  Год назад +1

      Looking at the code right now I do believe that you are right. The code I added isn’t necessarily wrong, but using auth()→user() is cleaner. use auth()->user(). If you need to retrieve user information based on a given condition, use User::where().

  • @NabeelPs-u6h
    @NabeelPs-u6h Месяц назад

    hi sir,
    while using command line please make sure to write at top or middle , on bottom it gets hide byy youtube texts.

  • @mohamedadel936
    @mohamedadel936 Год назад +1

    Thank you Dary 😍
    I learned a lot from this video ❤

    • @codewithdary
      @codewithdary  Год назад +1

      I'm so happy that you dod Mohamed! :)

  • @alidahud337
    @alidahud337 Год назад

    Hi,
    the expires_at value is still null after setting up the scheduler. As. I can see yours too. Any idea why?

  • @mohammadhosseinmoradi2021
    @mohammadhosseinmoradi2021 2 года назад +3

    It was very very useful. Thanks a lot to Mr. dary ❤for creating tutorial contents. Your tutorials are the best! I'm from iran country. I like next tutorial was be about the role based API and custom middleware. I look forward to your next tutorials.

    • @codewithdary
      @codewithdary  2 года назад

      Thank you so much Mohammad, I try to do my best for you :)

  • @bestepisodes5774
    @bestepisodes5774 Год назад +1

    Task::factory()->times(2)->create();
    Error Class "Task" not found.
    showing this error. Can you help me

    • @codewithdary
      @codewithdary  Год назад

      Ensure that the Task model file is autoloaded properly by checking your composer.json file. This can be done by running the following command: composer dump-autoload.

  • @XFX0629
    @XFX0629 Год назад +1

    Amazing tutorial. Extremely clear and useful. Thanks a lot!

  • @Ali-qq9hy
    @Ali-qq9hy 2 года назад +1

    On 27:34 , where did you get that Route/Password::default() method. I cant import it

    • @codewithdary
      @codewithdary  2 года назад +1

      Add the following use statement at the top of your file: use Illuminate\Validation\Rules;

    • @darn2926
      @darn2926 Год назад

      @@codewithdary the error still does not clear, I am using laravel 9

  • @afolabiabiodun7582
    @afolabiabiodun7582 Год назад +1

    You're too good. You made it easy

  • @mr_farukhaleem
    @mr_farukhaleem Год назад +1

    Thank you @codewithdary . Your video tutorial is very helpful and easy to learn. Which packages or feature of a Laravel should we learn more to make a complete app for backend API. like like for sending emails, que jobs, uploading files..

    • @codewithdary
      @codewithdary  Год назад

      You shouldn't really learn packages, because they usually have good docs. You need to level up your Laravel skills to learn APIs!

  • @EljayPucan
    @EljayPucan Год назад +1

    Question: Why did you use Trait instead of Laravel resources for API?

    • @codewithdary
      @codewithdary  Год назад

      If I’m correct, because It has been a while, I used the trait to determine the type of message that should be returned and the API resource to specify how the data should be returned.

    • @EljayPucan
      @EljayPucan Год назад

      @codewithdary I guess it needs version 2 of this awesome tutorial 🤗

  • @7Janiel
    @7Janiel 9 месяцев назад

    One thing to ask: why did you not create form requests for all the Task functions ?

  • @robinncode
    @robinncode Год назад

    Thank you very much. Your Tutorial was very clear and easy to learn. You are awesome!!!

    • @codewithdary
      @codewithdary  Год назад

      Thank you so much for your kind words, it's truly appreciated!

  • @edi_gun_awan
    @edi_gun_awan 10 месяцев назад +1

    Thank you. I retired from JS framework hell from now on.

  • @abrhamb2952
    @abrhamb2952 Год назад +1

    Best Course on Sanctum Thanks a lot ,
    Do you have Laravel Fortify Course ?

    • @codewithdary
      @codewithdary  Год назад

      Thank you so much Abrham! I unfortunately don't :(

  • @АлександрФефилов-х4т

    Great job Dary. But I forgot how to deal with this ""The PATCH method is not supported for this route. Supported methods: GET, HEAD, POST."," resource controller can not be used?

    • @codewithdary
      @codewithdary  Год назад

      What is the route?

    • @АлександрФефилов-х4т
      @АлександрФефилов-х4т Год назад

      @@codewithdary timing 1:09:26 error "message": "The PATCH method is not supported for route api/tasks. Supported methods: GET, HEAD, POST.",
      "exception": "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException", Please advise how to fix this error

    • @codewithdary
      @codewithdary  Год назад

      @@АлександрФефилов-х4т The patch method is used to update a resource, but you are trying to perform it on either retrieving or persisting a post. The endpoint for patch should be api/tasks/{id}

    • @АлександрФефилов-х4т
      @АлександрФефилов-х4т Год назад

      @@codewithdary thanks for the help. Inattentively looked, everything worked.

  • @kimelironald4451
    @kimelironald4451 2 года назад +1

    Good staff,,,You are really doing something Amazing. API is my favorite. Make a simple mysql cli tutorial, very short is enough

    • @codewithdary
      @codewithdary  2 года назад +1

      Thank you Kimeli! Not sure if I be doing that any time soon.

    • @kimelironald4451
      @kimelironald4451 2 года назад

      @@codewithdary No worry.Thanks

  • @md.ruhulamin7963
    @md.ruhulamin7963 2 года назад +1

    Thank you sir, this is very clear, simple and informative. One request, would you please add how to handle image in API. Thank you.

    • @codewithdary
      @codewithdary  2 года назад +1

      Thank you for watching Ruhul. It needs to happen in the same way as "not with APIs"!

  • @firassebai8592
    @firassebai8592 2 года назад +1

    Thanks for clearing me sanctum because many ppls says its for beginners ..
    Else i ve another question am starting deving some apps with laravel without using any packages like sanctum or passport for auth, are they not secured 🤔 do tou recommend to use sanctum .. already setup auth for *not small projects
    thank you

    • @codewithdary
      @codewithdary  2 года назад

      Glad I could help! Well I can’t say whether a custom auth system is secured or not without seeing it but you have to keep a lot of factors into consideration which are happening behind the scenes. I’m personally a fan of sanctum because of its simplicity, so I would recommend it (or Laravel passport for oauth2.0)

  • @mahdipaykoub9951
    @mahdipaykoub9951 8 месяцев назад

    It was great, but one question
    When we don't use the api of Laravel, the functionality of the register and login functions are implemented by Laravel. Is there no such api here?

  • @computer23able
    @computer23able Год назад +1

    Hi day , i made this tutorial three times but after this code : Task::factory()->times(250)->create();
    I got : Task class not found !!!?????!

    • @codewithdary
      @codewithdary  Год назад

      That happens when the factory class is not being autoloaded correctly. You could add the path to the file right in front of the model: such as App\Models\Task and then it works :)

    • @computer23able
      @computer23able Год назад

      @@codewithdary Could you please make this course for web too ?🎉 Its very easy and dont take your time 🎉

  • @Muhammed-nani964
    @Muhammed-nani964 Год назад +1

    Noice video Dary we need more videos about auth with api for SPA front-end, and I have a question about authentication for a project. I'm confused about whether to use cookie or token-based API authentication. Which one do you suggest and which one is more secure? especially for SPA front-end

    • @codewithdary
      @codewithdary  Год назад +1

      Hi Muhammed! It's difficult to judge without knowing the project's background. However, token-based authentication is useful for storing data on the client-side, while cookie-based authentication is suitable for storing less secure data, as cookies can be vulnerable.

  • @feedgaming8374
    @feedgaming8374 11 месяцев назад +1

    tysm, you are so good at explaining subjects like this, appreciate your efforts,

  • @ahmedsabri6275
    @ahmedsabri6275 Год назад +1

    this was so amazing and helpful
    thanks for this tutorial

  • @LeonelLopezBorbon
    @LeonelLopezBorbon 2 года назад

    That's magnific your tutorial more clear understand! Thank very much! TOP!

  • @ThaRealIansanity
    @ThaRealIansanity 2 года назад +1

    Small mistake in LoginUserRequest ? I think you referred to the 'email' rule as meaning it comes from the 'email' column. Actually validates that it is a properly formed email address. Also what is the need for 'string' rule if we are making sure it is a valid email? And for the password, Password::default() used in the register request rules has min:8 by default where we used min:6 in our login request. I just used Password::default() in both requests to make sure the rules match.
    Otherwise excellent course so far. I'm learning a lot and looking forward to moving to your authentication videos next

    • @codewithdary
      @codewithdary  2 года назад

      Thank you Ian! I'm here to learn too ;)

  • @__Cypher
    @__Cypher 2 года назад +1

    I have a question
    Why did you created Token at the time of User registration ??
    We are creating a token in login and if a user register then he will definitely going to do login

    • @codewithdary
      @codewithdary  2 года назад

      It's an educational tutorial, I can't just show users to register and end up with the video. Most apps have login/register. It's up to the viewers how they are going to implement it inside their working app :)

  • @jonroberts3333
    @jonroberts3333 2 года назад +1

    This works great locally, but as soon as I push to a remote dev site any request sent with the received Bearer token says "Unauthenticated". Anyone have any suggestions?

    • @codewithdary
      @codewithdary  2 года назад

      Could you try the solution from the following link please?
      stackoverflow.com/questions/72801429/why-bearer-token-not-working-on-my-server

  • @wikichua3577
    @wikichua3577 2 года назад +1

    i love all your tutorials. hope to learn more from your up coming tutorial, appreciated if there is laravel livewire and alpinejs tutorial.

  • @aminekoumni5075
    @aminekoumni5075 Год назад +1

    sanctum middleware is protecting only logout route but others no i don't know why please help

    • @codewithdary
      @codewithdary  Год назад

      You should check that the middleware is being properly applied to all relevant routes in your application, and that there are no syntax errors or other issues with your middleware code.

    • @aminekoumni5075
      @aminekoumni5075 Год назад

      @@codewithdary solved

  • @miyirbek6821
    @miyirbek6821 Год назад +2

    Thanks a lot bro. You helped me so much

  • @belaouraabdelwahab
    @belaouraabdelwahab 2 года назад +2

    Awesome video thanks 👍
    Please add more videos about API other methods like email confirmation, password reset, OTP confirmation for mobile .... Thanks again for the tutorial

    • @codewithdary
      @codewithdary  2 года назад +1

      Sounds interesting! But the code will pretty much be the same as I’ve build in my other tutorials!

  • @piyushjain9229
    @piyushjain9229 Год назад

    thanks sir you helped a lot to understand the basis of api and how to complex things in simple way

  • @sundayolaoye713
    @sundayolaoye713 Год назад +2

    HI Dary, I don't know what I did wrong in the 32min here 'password' => ['required', 'confirmed', Rules\Password::defaults()]. it was highlighting Rules\Password and was saying undefined type, I wouldn't know what I supposed to put in the name space on top.

    • @patrikhalgas7719
      @patrikhalgas7719 Год назад +3

      Hi, try 'password' => ['required', 'confirmed', Password::defaults()] and use Illuminate\Validation\Rules\Password;

    • @sundayolaoye713
      @sundayolaoye713 Год назад +1

      @@patrikhalgas7719, thanks Dary as explained to me in another course.

    • @vilhemleshi7222
      @vilhemleshi7222 Год назад

      I faced the same issue.

  • @w155uu
    @w155uu Год назад +1

    hope you complete this tutorial by adding an extra section about token abilities and authorization. thanks

    • @codewithdary
      @codewithdary  Год назад

      The tutorial is very complete, what you want is additions :)

  • @chinazamekperechimbo1980
    @chinazamekperechimbo1980 Год назад

    This tutorial is the best I have ever seen for laravel API. I was wondering, what visual studio code extension do you use to automatically pull in newly created controllers to the route file

    • @codewithdary
      @codewithdary  Год назад

      Thank you so much. ruclips.net/video/KAUxgUvC514/видео.html

  • @sundayolaoye713
    @sundayolaoye713 2 года назад +1

    Hi Dary, thanks for the good works. I am using VS code on windows, when you wanted to test your login in the 18mins of the video you typed laravel_sanctum.test/api/login. please, where is .test from? I have been trying and trying and keep getting errors on my postman? you also said we can use PHP artisan serve, I tried it in Postman it doesn't work?

    • @codewithdary
      @codewithdary  2 года назад

      I’m using Valet, that’s why I’m able to add the .test. If you don’t use Valet you should use 127.0.0.1:8000.

  • @chrisngkaixing320
    @chrisngkaixing320 2 года назад +1

    Nice video! Thank you for your great content, it's clear and easy to understand.

    • @codewithdary
      @codewithdary  2 года назад

      Thank you Chris! Hoped it help you out :)

  • @tond9997
    @tond9997 2 года назад

    I can't run schedulte auto expires token in my test project .
    Can you explaining more and check and deepdown with topic expires datetime how it real work right ?
    If your explain , Ser ' I appreciate that.

  • @RaV86pl
    @RaV86pl Год назад +1

    Great video again, love Your work. Just a question, can we use policies for sanctum API? feels like it should work and in this example it fits perfectly

    • @codewithdary
      @codewithdary  Год назад

      Yes you can!

    • @codewithdary
      @codewithdary  Год назад

      The reason why I didn't use policies is mainly because I nevr covered it in a separate video

  • @SR-hp4tp
    @SR-hp4tp 11 месяцев назад +1

    Amazing tutorial !

  • @hichamelbachari2655
    @hichamelbachari2655 Год назад +1

    what an amazing video!

  • @MrMozkoZrout
    @MrMozkoZrout Год назад +1

    Hey awesome video, I would just like to ask about that isNotAuthorised function that we created. Is there a reason it needs to be private ? And i mean i get that it is the right way but when it was created inside of the controller class shouldn't all other functions in that class be able to use that function ? I ask because i thought i will be able to replace the if statement in the update function and use the function not to have any redundant code but aparently the function update doesn't know the isNotAuthorised function. Why is that ? And if this doesn't work this way, how come the weird Ternary operator thingie could access the function ?

    • @codewithdary
      @codewithdary  Год назад +2

      First of all, thank you for your kind words.
      When I created the TasksController, I intended to use the isNotAuthorized method only within the controller itself and not in other classes. If you want to use the isNotAuthorized method in other classes, I suggest placing it inside the User Model where you can access it through auth()->user()->isNotAuthorized in any controller.
      Regarding your comment about the update method not knowing the isNotAuthorized function, I'm not sure what you mean. Could you please clarify?

    • @MrMozkoZrout
      @MrMozkoZrout Год назад

      @@codewithdary Oh hello, thank you for your quick answer. You are great. Oh I am sorry I wrote that comment at like 4 am and o was confused. I already figured it out. I simply forgot that I have to use $this-> in front of the function in order to use this. And after I did I forgot that I also have to return the output of the function so I thought the update controller is just ignoring it. It works now when I put it into a classic if statement there. I never intended to use it in another class, sorry for the confusion. Now I am just thinking how to change the function so it doesn't need to be called twice. Once for the if statement and once to return the error.

  • @gp6723
    @gp6723 10 месяцев назад +1

    Great one!

  • @fedihammami5141
    @fedihammami5141 Год назад +1

    if I want to get all tasks in my database or show the details of a specific task and make all users can do this, how can I implement this ??

    • @codewithdary
      @codewithdary  Год назад

      The functionality has been build in this tutorial, you shouldn't wrap it inside the middleware if everybody should be able to create tasks.

  • @tripmaster2840
    @tripmaster2840 Год назад +1

    Thank you very much Dary

  • @tricioandrade
    @tricioandrade 2 года назад +2

    Hello teacher, how are you?
    I'm having problems with the Class Validator while trying to register a user:
    {
    "message": "Method Illuminate\\Validation\\Validator::validateAndrade does not exist."
    }
    I've searched on stackoverflow and other forums but I haven't had success. I tried to include the Class Validator, but I didn't succeed either.
    And again, thank you for taking your precious time to create this instructional-rich video.

    • @codewithdary
      @codewithdary  2 года назад +1

      Have you added validateAndrade in your use statement? Other than that I have no idea and it doesn't seem like an error related to this tutorial.

    • @codewithdary
      @codewithdary  2 года назад +1

      I'm also doing good! What about yourself? :)

    • @ladirevolutionist
      @ladirevolutionist 2 года назад +1

      I got the same error. But I find that I typo in AuthController.php.
      incorrect : $request->validate($request->all());
      correct : $request->validated($request->all());
      I hope this will help you from Japan.
      And super thank you, Dary!!

    • @tricioandrade
      @tricioandrade 2 года назад +1

      Thanks ladirevolutionist. I'll try that

    • @tricioandrade
      @tricioandrade 2 года назад +1

      @@ladirevolutionist thank you.

  • @luisuran4050
    @luisuran4050 Год назад +3

    Something that bothers me is that on the update method you are giving the user the chance to update any field. I would instead do "$task->update($request->only(['name', 'description', 'priority']));"

    • @codewithdary
      @codewithdary  Год назад

      I'm happy you saw that. Honestly don't really have a reason why I used it inside the AuthController and not inside of the TasksController. Just a mistake on my part.

  • @charbel12334
    @charbel12334 Год назад +1

    getting a jumpscare with the start of each section😂. Very useful tutorial!
    Can you please make the frontend of this application with react js

    • @codewithdary
      @codewithdary  Год назад

      I have to keep my students awake you know :)

  • @tamilselvan-jas
    @tamilselvan-jas 2 года назад +1

    Thanks for the great tutorial, Can we validate the auth check in validation class, why we need a separate function in controller?, How to validate the type hinted model in form request class?

  • @mahamedassoul6960
    @mahamedassoul6960 2 года назад +1

    your tutorial was very very helpful, thank you so much 👏

  • @DionmarLariosa
    @DionmarLariosa Год назад +1

    does laravel 9 or 10 already have sanctum ? is it necessary to install it again? or its just i am wrong?

    • @codewithdary
      @codewithdary  Год назад

      It has been installed by default now yes, but I always try to show users that ou could install it manually if needed. I should've mentioned that it's optional though!

  • @dheeraj_kumar_1508
    @dheeraj_kumar_1508 2 года назад +1

    Thank you very much Sir i saw the video and practice well

  • @ElieShamout
    @ElieShamout Год назад +1

    Thank you very much,
    How i can check if Task is exists or no using FunctionName(Task $task)

    • @codewithdary
      @codewithdary  Год назад

      I recommend you to look into the findorFail method that Laravel offers :)

  • @guilhermefalciairescosta4363
    @guilhermefalciairescosta4363 Год назад

    when I give the tinker command to create task records I get the error that the class was not found, but the model exists called Task

    • @codewithdary
      @codewithdary  Год назад

      Then you need to add App\Models\ in front of it

    • @immajesman
      @immajesman Год назад

      Run 'composer dump-autoload' before 'Task::factory()->times(250)->create();'

  • @laravelug
    @laravelug 10 месяцев назад +1

    Thnx for the video, how can we implement roles and permission

    • @codewithdary
      @codewithdary  10 месяцев назад

      Laravel Spatie Roles and Permissions :)

  • @kh1amirhamza
    @kh1amirhamza Год назад +1

    Wonderful Tutorial!

  • @stuarttodd1875
    @stuarttodd1875 Год назад +1

    This is great, thank you

  • @umar_adil
    @umar_adil 2 года назад +1

    This is a nice work and it helped me to improve my sanctum integration and few shortcuts. I am also listing out all users to list without login by any user how can I prevent that API from public access?

  • @nsolomonsudhirprabhakar7317
    @nsolomonsudhirprabhakar7317 2 года назад

    checking with postman is ok, but it is very difficult sending headers from client side, though the token is sent, 401 response is showing

    • @codewithdary
      @codewithdary  2 года назад

      I understand your frustration but everyone has their own tooling. I personally love using Postman.

  • @sale7680
    @sale7680 2 года назад +1

    Dary u use which extension for auto import?

    • @codewithdary
      @codewithdary  2 года назад +1

      Here you go: ruclips.net/video/KAUxgUvC514/видео.html&t

  • @binaryfire
    @binaryfire Год назад +1

    Great video Dary! I have a regular Laravel / Blade app and was thinking of dropping a small SPA into one of my pages. Is it possible to make authenticated API calls from that SPA using Sanctum, even though the user logged in via the normal Blade login page (session auth)? I’d prefer to use Sanctum’s session authentication for security. The SPA is on the same domain as the API.

    • @codewithdary
      @codewithdary  Год назад

      I don't really see the point of using an API is you want to use it within the same project, unless you want to fetch data to other apps as well. Usually, you create a backend API and use it within a JS Framework.

    • @binaryfire
      @binaryfire Год назад

      @@codewithdary So basically, we're replacing one section of a large legacy app with a Vue SPA for better UI/UX. It'll need to consume the API to work. I figure there must be a way to do it since Sanctum supports session auth for SPAs. But I can't find any examples or info. The page with the SPA will be /my-account and the api is at /api. So they're both on the same domain.
      The API will be used for a mobile app in the future so we'll be creating it anyway. Our Vue dev is an experienced frontend dev and doesn't want to use Inertia.

    • @naiveneger39
      @naiveneger39 7 месяцев назад

      ​@@binaryfire did you find the solution?

  • @JanLordLuga
    @JanLordLuga 2 года назад +1

    great tutorial. Thank you!

  • @codewithdary
    @codewithdary  2 года назад +3

    YOU CAN FIND ME ON TWO NEW PLATFORMS.
    🔥TikTok: www.tiktok.com/@codewithdary
    🔥Blog: blog.codewithdary.com/
    AND ON
    🔥Instagram: instagram.com/codewithdary/
    🔥Twitter: twitter.com/codewithdary

  • @aisalen
    @aisalen 2 года назад

    Thanks for this great and clear tutorial! Hoping that you can continue creating tutorial for vue or react consuming the api from this.

    • @codewithdary
      @codewithdary  2 года назад +1

      Definitely something I'll be doing very soon!

    • @tukurhamid
      @tukurhamid 2 года назад

      @@codewithdary can't wait 👍

  • @Psychobellic
    @Psychobellic 2 года назад +1

    Great content, Dary. Thank you!!
    Just wanted to add that I had some issues on the authentication, always getting Unauthorized back, even using traits.. But my issue was that I was using Breeze as starter kit, so I had to start a new project to make it work properly. It does now,
    I just don't understand why we create a token on register and a new one on login? Can you explain, please?

    • @codewithdary
      @codewithdary  2 года назад +1

      Laravel Breeze doesn't use Sanctum! You need to look into that to get more clarification :)

    • @AlexGower
      @AlexGower 2 года назад

      Laravel breeze -api uses sanctum all you need to do is get csrf before try to login etc and then it will refresh the csrf with every authenticated request

  • @luisdev7646
    @luisdev7646 Год назад +1

    thank you very complete tutorial

  • @johwel340
    @johwel340 2 года назад +1

    super content. Thanks Dary.

  • @jtech04
    @jtech04 2 года назад +1

    Awesome dude, for covering advance topic😁😁

  • @ulaskorpe
    @ulaskorpe 10 месяцев назад +1

    thank you for this tutorial

  • @soliuabdulkadir4488
    @soliuabdulkadir4488 Год назад

    Pls I am stuck. I couldn't get to make tinker populate my tasks table. It is returning " class Task not found". Pls come to my aid

    • @codewithdary
      @codewithdary  Год назад

      You should add the namespace in front of the model so App\Models\Task.

  • @williamadil
    @williamadil 4 месяца назад

    Good stuff 👍

  • @chamath100
    @chamath100 2 года назад

    How to handle show/destroy methods when passed id is not exist in the database?

  • @aouraghmohammedelamine5744
    @aouraghmohammedelamine5744 Год назад +1

    thank you Dary for the tutorial it's very rich with informations and best practices , can you please update the repo ?

    • @codewithdary
      @codewithdary  Год назад

      Thank you so much. What is missing in the repo?

  • @7Janiel
    @7Janiel 9 месяцев назад

    Very good tutorial sir