Store and Update routes - How to make a Laravel CRUD API Tutorial #4

Поделиться
HTML-код
  • Опубликовано: 4 июл 2024
  • In this tutorial we will add the store and update methods to our controller.
    Get the code here:
    github.com/QuentinWatt/how-to...
    Follow me on social media:
    Twitter: @QuentinWatt
    Facebook: @quentinwatt
    Instagram: @quentinwatt
    Subscribe:
    / quentinwatt
    I also make videos here:
    / quentin
    Donate with Paypal:
    www.paypal.com/cgi-bin/webscr...

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

  • @davidson7838
    @davidson7838 3 года назад

    I am wondering how I have missed your tutorials on youtube! You are so wonderful teacher. I really liked your videos on react & laravel etc....
    Thank you so much.

    • @QuentinWatt
      @QuentinWatt  3 года назад

      Thank you so much!

    • @davidson7838
      @davidson7838 3 года назад

      @@QuentinWatt can you make a fresh series on reactjs / vuejs? Or one out of the two which prefer more?
      Thank you so much.

  • @ernstjacobs2341
    @ernstjacobs2341 5 лет назад +3

    Just wanted to say, good job on the videos mate, they're really good. Clear language, good footage and most importantly, good code examples! Keep it going bud.

  • @QuentinWatt
    @QuentinWatt  5 лет назад +9

    Did you know sharing this video on your facebook will help my RUclips rankings?

  • @adil.bashir
    @adil.bashir 3 года назад

    Thank You man finally found some real stuff for API. Really appreciate your work keep it up.

  • @KgfLikia
    @KgfLikia 5 лет назад +1

    I already made a project in laravel without API, those videos really helpful, I am going to build it with API + ReactJS front, awesome videos newest laravel version

  • @ernstjacobs2341
    @ernstjacobs2341 5 лет назад +2

    I just have one thing to add though. It might be good practice to put the validation in a new Request file. 'php artisan make:request PersonStoreRequest' This way you can keep the controller really clean and have everything separated.

  • @prem007mano3
    @prem007mano3 4 года назад +1

    what a brillent guy in my life.work 100 full effort.Allah bless you.i am promoting your channal .

  • @jeps7688
    @jeps7688 4 года назад

    I've been learning php for almost 3 days. I'd learn the basics and after 1 week I can create restful api with it. bunch of tutorials here in youtube include the stuff i dont need like templating and some other stuff i dont care about. I only need an API for my mobile app. thanks to your video mate.

  • @febrarisupaldi9448
    @febrarisupaldi9448 5 лет назад +1

    Thank you for all tutorial about laravel, i just want to learn about laravel , i usually using native php hahahaha

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      Laravel will change your life man.

  • @daledurham3048
    @daledurham3048 4 года назад +1

    You CAN use FormData and in fact most real-world clients will send it as FormData,. You just have to method spoof it (laravel.com/docs/5.8/routing#form-method-spoofing). In Postman, if you use FormData and add an extra field named _method with a value of PUT, it should work. Laravel will take care of mapping it on the server. This is vital for thing like files which only FormData supports.

    • @QuentinWatt
      @QuentinWatt  4 года назад

      For testing the API with postman it's okay to even send a raw query. It's really just there to test how our data is handled.
      While FormData is 1 way to accept data. You can also send HTTP requests with Axios which will support put and patch methods. It all depends on the use case.

  • @alia.dhillon6224
    @alia.dhillon6224 4 года назад

    The other way is to send a POST request with an additional form argument of "_method:PATCH" to tell the laravel that it is actually a PATCH request and it works just fine.

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      That's for HTML forms where Patch is not a supported method, but this works just fine using axios.patch() or some javascript method like that.

  • @andreygritsay762
    @andreygritsay762 4 года назад +1

    Instead of 'form data' you just need to use 'form url encoded' so you don't need to use raw query

  • @richiejenkins2512
    @richiejenkins2512 4 года назад +1

    Should store() in the controller have a return type of PersonResource also?

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      It does in my final project
      github.com/QuentinWatt/how-to-make-an-api-with-laravel/blob/master/app/Http/Controllers/Api/v1/PersonController.php

  • @TheSvs1
    @TheSvs1 5 лет назад +1

    tutorial 4 -> how does it knows which ID it needs to update? you pass it in the URL but i see no reference to it in the code.
    it is a built in feature? (like it shows on the route:list?)

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      It accepted the ID and used the Person model to find the correct person.
      That was what this part is for.
      `Person $person`

  • @salarkafashan9367
    @salarkafashan9367 3 года назад

    Hello, first of all i wanna say your tutorials are amazing, and I have question about restControllers, for example in update or show method if person doesn’t exist! How we can show errors , i always use try catch but i want to know about rest controllers

    • @QuentinWatt
      @QuentinWatt  3 года назад +1

      Following this course, Laravel will automatically throw an exceptions with a message for examples you have mentioned.

  • @rameshbabusowpati6123
    @rameshbabusowpati6123 4 года назад

    Hey, Thanks for the Tutorials, I liked it very much. I tried to built small api using this notes. And also can you please provide the way to install CORS Middleware on this API?

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      Laravel 7 actually has a CORS package shipped as default, but you can install it from here:
      github.com/fruitcake/laravel-cors
      You simply set the allowed origins as an array in the config file. Instructions are in the Readme file of the repo.

    • @rameshbabusowpati6123
      @rameshbabusowpati6123 4 года назад

      @@QuentinWatt Thank you. You are a pro...

  • @adil.bashir
    @adil.bashir 3 года назад

    Could you please recommend me the advanced API course.Thank You in advance.

    • @QuentinWatt
      @QuentinWatt  3 года назад

      I'm not sure who to recommend but there are plenty of courses like this on udemy.

  • @MimisK88
    @MimisK88 4 года назад

    How can pass csrf token to postman ???

    • @QuentinWatt
      @QuentinWatt  4 года назад +1

      You can set those in the headers tab. Add a token and then get the token from your browser.
      Although csrf token is for a web route.
      Typically an API would use a different guard and require a bearer token.

  • @prem007mano3
    @prem007mano3 4 года назад

    update data nahi hu raya ?

  • @prem007mano3
    @prem007mano3 4 года назад

    "message": "The PUT method is not supported for this route. Supported methods: GET, HEAD, POST.",

    • @_nickpashkov
      @_nickpashkov 4 года назад +1

      Make sure you are sending the request to /person/, maybe you are sending a put request to /person

    • @QuentinWatt
      @QuentinWatt  4 года назад

      As NickyP pointed out. You may be using the wrong route. I show you how to check routes at 1:11

  • @prem007mano3
    @prem007mano3 4 года назад

    sir update nahi hu raya