Laravel clean code: keep controller clean and git rid of if statement

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

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

  • @mohamadaghi6756
    @mohamadaghi6756 27 дней назад

    Top laravel instructor in youtube
    Keep up the good work my boy ❤❤

    • @laravelboy
      @laravelboy  27 дней назад

      اخويا ابو عمر ، الله يسعدك

  • @jtech04
    @jtech04 28 дней назад +3

    which extension you are using to show placeholders like: "table: ...., column: ..... :array..... etc" ??

  • @julienSibille
    @julienSibille 27 дней назад

    This one is awesome !

  • @Alex-nm9nr
    @Alex-nm9nr 28 дней назад +1

    Good advice, but bad example. I think it's better to create custom validation rule in this case. This will allow tu return more appropriate error message.

  • @amazingrajeev
    @amazingrajeev 27 дней назад

    i think validation purpose should be to check product_id field whether it is exists or not , you are avoiding single responsibility by doing this. But adding middleware in authorize section could be better since it avoids extra meaningless checks on validation rules.

    • @laravelboy
      @laravelboy  27 дней назад

      You have a valid point. Middleware is a good approach too

  • @eslammostafa1247
    @eslammostafa1247 29 дней назад

    This tip is new to me
    thank you

  • @abdulbasitrana2743
    @abdulbasitrana2743 20 дней назад

    Great tips.

  • @daveb8795
    @daveb8795 29 дней назад +3

    Why add 50 lines of code in 4 different places to replace 1 if statement? I don’t understand the logic of that??

    • @k_fc_
      @k_fc_ 28 дней назад +4

      welp, its for teams and clean code. but if you are a solo player then I don't see there is a need for that. i tried this way and its just very exhausting one thing leads to another and so on.
      sometimes You need this random code or (not clean code).

    • @Takatou__Yogiri
      @Takatou__Yogiri 28 дней назад +1

      I dont know php but organizing your code is good practice. And if you want a job then you must be good at organizing your code. Built a real world application and you will understand it yourself.

    • @daveb8795
      @daveb8795 28 дней назад +1

      @@Takatou__Yogiri I fire people that do this.

    • @k_fc_
      @k_fc_ 28 дней назад

      @@Takatou__Yogiri as i said man. opinions may differ

    • @Hassam-deno
      @Hassam-deno 27 дней назад

      for scalability.

  • @SeyedMansour27
    @SeyedMansour27 28 дней назад

    thanks for making great videos, but i have to disagree with this one, you are reducing the code readability (main point), and also you can't re-use that request if you have orders in other places.
    i prefer to do those checks in a service or somewhere that code reader naturally expects

  • @abdallakaram5376
    @abdallakaram5376 29 дней назад +2

    Its wrong because what about the product doesn't exist the user will get wrong message

    • @laravelboy
      @laravelboy  28 дней назад +1

      the message can be more customized too

    • @abdallakaram5376
      @abdallakaram5376 28 дней назад

      @@laravelboy its not about customize message its about there is two kind of error message the first one about the quantity and the second should be about product not found in your solution u cant because every rule has one message

  • @roman_zabigaliuk
    @roman_zabigaliuk 29 дней назад

    Great job

  • @fifthavenue2105
    @fifthavenue2105 29 дней назад

    Thanks 🙏

  • @حسينابراهيمعبدالرسول

    but for me prefer middlewares

    • @laravelboy
      @laravelboy  29 дней назад

      it's a great solution too