#21 Laravel API Tutorial | Laravel Webhook API | Update Stock via Laravel Webhook | Stock Webhook

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024
  • In Part-21 of Laravel 8 API Tutorial, we will continue working for Stock Management that we will do with Laravel Webhook API this time.
    In this video, we will work on Laravel Webhook or we can say Laravel Webhook API to update the stock at client database from the server but server will call client API when there is update in stock.
    There is no 3rd party Stock API link that we need to call with Curl but we will create our own API link that we will provide to 3rd party to hit that API URL whenever there is any change like update in stock.
    Steps for creating Stock Webhook API in Laravel :-
    1) Create Tables :-
    Create products table with below columns :-
    id, name, status, created_at, updated_at
    Create products_attributes table with below columns :-
    id, `product_id, sku, size, price, stock, created_at, updated_at
    Insert some dummy products and attributes into the tables.
    2) Create Route :-
    Now, create post route for webhook in api.php file like below :-
    // Webhook POST API - Update Stock
    Route::post('update-products-stock','APIController@updateProductsStock');
    3) Create updateProductsStock function :-
    Now create updateProductsStock function at APIController to update stock of the products at products_attributes table. We will check Authorization first and then update stock of all items provided in json request send by the 3rd party.
    Headers :-
    Authorization : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFtaXQgR3VwdGEiLCJpYXQiOjE1MTYyMzkwMjJ9.cNrgi6Sso9wvs4GlJmFnA4IqJY4o2QEcKXgshJTjfNg
    POST :- 127.0.0.1:8000/api/update-products-stock
    Body: Raw data
    {
    "items":[
    {
    "sku" :"BCT-S",
    "stock" :23
    },
    {
    "sku" :"RCT-S",
    "stock" :45
    }
    ]
    }
    #laravelapitutorial #laravel8api #laravelapitypes #laravelapiexamples #laravelapi #laravelwebhook
    Learn to make e-commerce website in Laravel 6 / 7 / 8 :-
    • Laravel Tutorial for B...

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

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

    Webhook and API's are almost same or we can say both are in actual API's right ?

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

      There is some difference in both. If you need to receive data or notifications in real-time, you should look to use webhooks. But if there isn't a time-sensitive need for the data or notifications, or your integration requirements extend beyond POST requests, REST APIs are likely a better approach.

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

    Hi, can you plz make stripe webhook criteria when we use subscriptions ?

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

      Hi thanks for the suggestion... I will try to do in new Laravel 10 series

  • @MostafaAli-ou5uz
    @MostafaAli-ou5uz 3 года назад +1

    This tutorial is consists of eCommerce laravel 8 project series
    ???

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

      This series is still at the starting phase covering all types of Api's that can be used in Laravel websites and very soon going to start API's for E-commerce series.. It's going to be biggest and deepest online Laravel API's series that will cover everything..

    • @MostafaAli-ou5uz
      @MostafaAli-ou5uz 3 года назад +1

      @@StackDevelopers
      u r awesome really
      and when can u begin at b2b series

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

      Very soon with Laravel 9 launch

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

    Please also make videos on OOPS CONCEPT

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

    Can you plz do " stripe webhook integration laravel with cron job alerts subscription stripe flow" ?

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

    why you don't use illuminate\Support\Facades\Http dude?

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

      Where? Please elaborate.

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

      @@StackDevelopers curl is php native library, and you can use illuminate\Support\Facades\Http for Laravel Project

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

      @@VanVangka Exactly

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

    i want the repo ::c

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

      Please join as a member to get source code
      ruclips.net/channel/UCExO2i-tLU1NyVZD6zOJQlwjoin

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

    exception "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException"
    file "C:\\xampp\\htdocs\\blogfood\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\AbstractRouteCollection.php"
    line 43
    e error change password keyup function time aa ahi hai plz help

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

      What are you trying to do? Send me more details and always try to debug your code..