CodeIgniter 4 RESTapi Server - Part 2 - CRUD Operations

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

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

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

    Great RESTful API tutorial for CI4, thank you Alex!
    I just spent 40 minutes trying to find out why my updating method wasn't working. I'm posting here just in case somebody else gets into the same tar pit. I was getting this 403 forbidden response when trying to update the blog post. The reason is I'm working on a public domain, not localhost. In this case I was only allowed to use GET and POST methods. So I changed to POST and still couldn't get it to work. It turns out that when changing to POST I also have to change the Presenter Route to add the 'update' on the URL as blog/update/(:blog_id)

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

      Hello, I'm using "resource" and I just want to add manually an alternate $routes->post('events/(:segment)', 'Events::update/$1'); that replace PUT and PATCH (because with axios it doesn't work well). But it doesn't work for some reason! I don't understand why.
      Since presenter and resource are very similar, can you help me to understand? (I already found a workaround, but this thing keep bugging me)

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

    I don't understand why codeigniter 4 provide so many ways to do the same thing, but some are too much automated (and obscure, since the confusionary or lacking documentation). I'm very confused.

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

      I feel the same when compare it with CI3. It just get a little bit more clear when i started to familiar myself with the autoloading

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

    thank you alex you are great

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

    Thanks you alex you really teach me a lot . About oauth2 . When token expired how can we renew the token without re-login? Thanka you in advance

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

    Thanks Alex, how do i create an endpoint with a custom query?

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

    14:02 This 'action not implemented' problem is fixed in CI4 version 4.1.1

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

    Hi Alex, thanks for the video. I'm a long time user of Codeigniter 2 but never made the jump so your videos are fantastic. Just a curiosity. In this line... return $this->failValidationError($this->validator->getErrors()); I get an the following error; Argument 1 passed to CodeIgniter\\RESTful\\ResourceController::failValidationError() must be of the type string, array given. Now, I could loop the array from the getErrors() function but I'm curious how you would handle that. Thanks

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

    Hi Alex, Great video, but I will like to know how I can loop through an array and add additional data to it
    Eg: $shops['shops'] = $model_shop->getShops($user['user_id']); now I want to add additional data foreach array in $shops['shops] , and return $this->respond($shops);

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

    how to pass http basic auth from CI not from postman?

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

    Hello Alex.
    Your tutorial is amazing.
    I have a question, I hope You can answer this.
    I need limit the delete of the posts to one or two users. How can I do that?
    Thanks.

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

    Hello how can i get the current user connected

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

    Hi alex, sorry my english is bad
    I want to ask. why is $ this-> model-> insert ($ data) not working in my place, I have tried checking with var_dump ($ data) and it has data but after that var_dump ($ post_id) has no data contents

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

      Hey, Muhammad, can you post your code somewhere so that I can see it?

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

      @@AlexLancer github.com/mhmmdhasnan/restapi/blob/master/app/Controllers/Blog.php
      This is my link github alex

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

      helo your api is working
      ?????
      i realy need in my project

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

      plz plz answer

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

      @@helpingjini8837 wait

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

    How to make crud image sir?

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

    Amazing video!

  • @VijaySingh-nc4ls
    @VijaySingh-nc4ls 4 года назад

    Hi Alex, I want to create Rest API in modules. How can we achieve this.

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

      Shouldn't it be the same way ?

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

    Hi Alex, it's a fantastic video :) But I have a question, how can I know the update was successful or not?

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

      Hi, Arun, if the response of the request is successful then the update is successful. Or what exactly do you mean?
      If the update would fail, you would get an error

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

      @@AlexLancer Hi, probably what he meant is what if he updated the blog that is not exists, what the response would look like. Because in your update API didnt provide checking wheter blog is exsited or not before updating it

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

    Hi Alex, this is my request, please try to make any simple application using ci rest API with react framework

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

      Hey, I am not into react. I use VueJS for my SPA projects.

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

      @@AlexLancer then u have any ideas to use Vuejs with CI 4 ???

    • @AlexLancer
      @AlexLancer  4 года назад +3

      @@unboxkarunadu372 I might do a video with VueJS using this RESTapi project

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

      @@AlexLancer Yes please! :)

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

      @@AlexLancer flutter bro pleasseeeeee

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

    1st like

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

      Thanks for being the first😀

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

    How we can add query into uri segment like localhost/request/update?t_id=12354567

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

      why would you use t_id as argument?
      I would ve use localhost/request/update/12354567
      class Request
      function update(t_id){
      echo t_id; ///would print 12354567
      }

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

      @@AlexLancer I want to get a request based on t_id(Terminal Id) instead of request_id(Primary Key).