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

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

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

  • @mohamadaghi6756
    @mohamadaghi6756 Месяц назад

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

    • @laravelboy
      @laravelboy  Месяц назад

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

  • @jtech04
    @jtech04 Месяц назад +3

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

  • @julienSibille
    @julienSibille Месяц назад

    This one is awesome !

  • @abdulbasitrana2743
    @abdulbasitrana2743 24 дня назад

    Great tips.

  • @eslammostafa1247
    @eslammostafa1247 Месяц назад

    This tip is new to me
    thank you

  • @daveb8795
    @daveb8795 Месяц назад +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_ Месяц назад +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 Месяц назад +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 Месяц назад +1

      @@Takatou__Yogiri I fire people that do this.

    • @k_fc_
      @k_fc_ Месяц назад

      @@Takatou__Yogiri as i said man. opinions may differ

    • @Hassam-deno
      @Hassam-deno Месяц назад

      for scalability.

  • @amazingrajeev
    @amazingrajeev Месяц назад

    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  Месяц назад

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

  • @Alex-nm9nr
    @Alex-nm9nr Месяц назад +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.

  • @fifthavenue2105
    @fifthavenue2105 Месяц назад

    Thanks 🙏

  • @abdallakaram5376
    @abdallakaram5376 Месяц назад +2

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

    • @laravelboy
      @laravelboy  Месяц назад +1

      the message can be more customized too

    • @abdallakaram5376
      @abdallakaram5376 Месяц назад

      @@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 Месяц назад

    Great job

  • @SeyedMansour27
    @SeyedMansour27 Месяц назад

    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

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

    but for me prefer middlewares

    • @laravelboy
      @laravelboy  Месяц назад

      it's a great solution too