Laravel Foreign Keys: How to Deal with Errors

Поділитися
Вставка
  • Опубліковано 24 жов 2024

КОМЕНТАРІ • 36

  • @santysasa12
    @santysasa12 3 роки тому +11

    The amount of knowledge you provided me for my work and studies is priceless. Thanks a lot!

  • @ricko13
    @ricko13 3 роки тому +9

    Man I love your videos, so glad I've found your channel just now 👍👍👍

  • @Admirul
    @Admirul 3 роки тому

    thanks sir. Greetings From Java Island

  • @mubarakb7
    @mubarakb7 3 роки тому

    You are LEGEND, That's it.

  • @GergelyCsermely
    @GergelyCsermely 3 роки тому +1

    It was for me a gap filling video. Thanks again.

  • @faridqanet4709
    @faridqanet4709 Рік тому

    Thanks for the informative video🙂

  • @francofourmantin481
    @francofourmantin481 3 роки тому +1

    short and concise, thank you!

  • @pierdocks5412
    @pierdocks5412 3 роки тому +2

    Very informative. Keep up your great work!

  • @wardy1295
    @wardy1295 3 роки тому

    Thank you sir. It helps me a lot ❤️ i had an issue of this error.
    Now its fine now ❤️❤️

  • @aculz
    @aculz 3 роки тому

    awesome video
    this method is working properly, but me personally will take Soft Delete way to keep the user in DB for history purpose instead of disable the delete

  • @SandeepBaraskarWebDeveloper
    @SandeepBaraskarWebDeveloper 3 роки тому +1

    Nice one 👍
    But i prefer to soft delete functionality, if it's a master data...

  • @Felipe-ez5gg
    @Felipe-ez5gg Рік тому

    thanks for the amazing content!

  • @nandopookey9195
    @nandopookey9195 Рік тому

    Thank you so much sir

  • @matteored
    @matteored 3 роки тому +1

    Hi, good video! I noticed that you use a mac for programming. Is it a version with m1 chip? What tools do you use to program locally in Laravel? Thank you!

  • @awadalsharif3953
    @awadalsharif3953 3 роки тому

    thanks man thats help a lot ..

  • @gayankavinda9757
    @gayankavinda9757 8 місяців тому

    thank you very much

  • @sightskill904
    @sightskill904 3 роки тому

    thanks sir.

  • @codewithtee
    @codewithtee 3 роки тому +1

    Great one, thanks for this beauty
    How do you you return this error, when dealing with API?

    • @LaravelDaily
      @LaravelDaily  3 роки тому +3

      Good question, it depends on what you want to return and how. I guess the best way would be try-catch and then in exception return validation exception with code 422, or error message with code 400 or 500.

    • @codewithtee
      @codewithtee 3 роки тому

      @@LaravelDaily thanks for the clarification 🙂

  • @eslamsobhy5692
    @eslamsobhy5692 3 роки тому

    GREAT video actually!!
    Thank you! :)

  • @Stoney_Eagle
    @Stoney_Eagle 3 роки тому

    I fill tables from an api and I've created foreigns to parent and grandparent but it gave me soo many errors on the parent relation that I just had to remove that relation.
    These foreign key constraints can be a huge headache sometimes.

  • @marcinmaj3609
    @marcinmaj3609 3 роки тому

    Please record video with categories and subcategories with view and dynamic route. Single view with boxes as link to subcategories

  • @ezichiebere3168
    @ezichiebere3168 3 роки тому

    Nice tips as usual. How do you add something like "updated_by" foreign key?
    Example: posts (table)
    id
    body
    user_id (Foreign key related to user)
    update_by (Another foreign key related to user)

    • @LaravelDaily
      @LaravelDaily  3 роки тому

      public function user()
      {
      return $this->belongsTo(User::class, 'user_id');
      }
      public function updated_by()
      {
      return $this->belongsTo(User::class, 'updated_by_user_id');
      }

    • @conspilt5021
      @conspilt5021 Рік тому

      @@LaravelDaily why updated_by_user_id instead of updated_by?

  • @shashi2749
    @shashi2749 3 роки тому

    Hi can you pls let me know about the Cors error. I have installed the fruitcake pkg for cors but it does not work. Can you pls help me out

  • @HamidAliOfficial
    @HamidAliOfficial 3 роки тому

    it is easy if we have single relation. if there are more relations code will become messy, I have tried using an isDeletable function on the model and checking for all relation counts in that function. Any better approach for this?

    • @LaravelDaily
      @LaravelDaily  3 роки тому +2

      It depends on the situation, with more relations there's no one way to un-mess the code :)

  • @robiulalam714
    @robiulalam714 3 роки тому

    Thanks, plz make a video on count() error in different php version

    • @LaravelDaily
      @LaravelDaily  3 роки тому

      count() error? What do you mean exactly?

    • @nurbolatnurlanuly
      @nurbolatnurlanuly 3 роки тому

      @@LaravelDaily Hello dear teacher) Is it possible to make dynamic filtering for products (I mean by many characteristics that defined by admin which we don't know), I've alreay seen your Laravel-Vue-Sidebar-Filters project

    • @LaravelDaily
      @LaravelDaily  3 роки тому +1

      @@nurbolatnurlanuly I'm not a big fan of making some script of filtering for DYNAMIC characteristics which are not known upfront, because each characteristic may have its own different behavior and then that filtering would break.

  • @danorex9100
    @danorex9100 3 роки тому

    The code in the controller doesn't look neat enough, you can use "Policies".

    • @LaravelDaily
      @LaravelDaily  3 роки тому

      Yes, the code itself is from one of my student junior developers, I didn't comment on that part of the code, only the deleting part.