4 Tips to Improve Leah's Laravel Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ต.ค. 2024
  • I saw a great candidate for a quick code review, so, here we go!
    Links mentioned in the video:
    Original video by Leah: My First Laravel Project & Initial Thoughts • My First Laravel Proje...
    Follow Leah's journey on Twitter: x.com/LeahTCodes
    - - - -
    Support the channel by checking out my products:
    My Laravel courses: laraveldaily.c...
    Filament examples: filamentexampl...
    Livewire Kit Components: livewirekit.com
    - - - -
    Other places to follow:
    My weekly Laravel newsletter: us11.campaign-...
    My personal Twitter: / povilaskorop

ความคิดเห็น • 26

  • @TheCodeholic
    @TheCodeholic 4 วันที่ผ่านมา +23

    Getting outside of comfort zone is very hard, so bravo to Leah for starting her journey publicly. I personally become nervious even only imagining doing live coding and I not remembering something or not knowing very basic thing. I think I need to work on this.

  • @TalesGrechi
    @TalesGrechi 4 วันที่ผ่านมา +11

    I remember that I did a lot of these "Model::all()" mistakes in the past, too...
    Great video!

  • @edgarsloskots2617
    @edgarsloskots2617 2 วันที่ผ่านมา +5

    My favorite sentence - “What if you have 1M problems in your database”? 😅

  • @saravanasai2391
    @saravanasai2391 4 วันที่ผ่านมา +3

    That was really a great review & constructive suggestions. I have seen some videos just roasting the creator for their code. Great job keep doing it.

    • @bumblebity2902
      @bumblebity2902 4 วันที่ผ่านมา +1

      In the companies participating for junior positions you get tough love reviews.

  • @p30mehrdad
    @p30mehrdad 3 วันที่ผ่านมา

    with this code review you did the great job. thank you.🌹

  • @5cmDuro
    @5cmDuro 4 วันที่ผ่านมา +1

    A while ago, I started using Model::query()->find($id) instead of Model::find($id). It's more verbose, but I gain the benefit of autocomplete and IDE intellisense, as it knows that find returns the model and not a mixed type.

  • @emmanuelsiziba5142
    @emmanuelsiziba5142 4 วันที่ผ่านมา +1

    Learnt something new... Esp about methods in controller rather than model

  • @zkabadu
    @zkabadu 4 วันที่ผ่านมา +2

    She could also return the return value of Quit::create() as the latest created model instead of dismissing the value and fetching it again from the database.

  • @bumblebity2902
    @bumblebity2902 4 วันที่ผ่านมา +1

    Kudos for Lady courage.

  • @IlPandax
    @IlPandax 4 วันที่ผ่านมา +2

    I really like these tips, BUT, be cautious when using "fresh" because if you have other tables in the DB you are using for your laravel tables (for whatever reason), they will ALL be deleted, not only laravel tables.

  • @drewbertola
    @drewbertola 3 วันที่ผ่านมา

    (@ 2:03) You would actually prefer this outside of the controller? Traditionally the controller is for business logic, not just a proxy for a crud model. I'd hate to go into code that buried business logic deeper because it didn't match a CRUD operation.

    • @LaravelDaily
      @LaravelDaily  2 วันที่ผ่านมา +1

      Controller is for business logic? Maybe you're coming from other framework/language? In Laravel, the goal of controller is to, well, CONTROL, get the parameters, call the logic methods, return the results.

  • @shahsawoodshinwari
    @shahsawoodshinwari 4 วันที่ผ่านมา +2

    Actually i am not a fan of things to do in services instead i do that in models and have my dedicated package called Laravel trait generator which generates those traits fir me.

  • @aimperialdesign6519
    @aimperialdesign6519 6 ชั่วโมงที่ผ่านมา

    I have also new project. If want to post it, wouldn't it affect exposing the code?!
    The project was used during the Miss Tabuk 2024 and I'm currently making the version 2 to do users feedback.
    What ja think?

    • @LaravelDaily
      @LaravelDaily  6 ชั่วโมงที่ผ่านมา

      Depends on what and how you expose, there are different projects, no single rule for this.

    • @aimperialdesign6519
      @aimperialdesign6519 6 ชั่วโมงที่ผ่านมา

      ​​@@LaravelDaily I've learned a lot from you. So, I refactor the queries. Would it be good if I'll show it in public when it will be used by the community?
      I'm new to web development. I'm starting to learn PHP and JS both without framework but halted due to have to rush the project. And tried Laravel based on my VB knowledge. So, I don't I actually know most of your coding style previously because I tried eloquent from the start.
      My controllers have bunch of codes while yours are just few lines. But still manage to made it work well and load efficient for some maybe.

    • @LaravelDaily
      @LaravelDaily  5 ชั่วโมงที่ผ่านมา

      I don't really understand the question. Where do you want to show it and how? You don't need MY permission to show your code somewhere :)

  • @chlouis-girardot
    @chlouis-girardot 4 วันที่ผ่านมา

    Maybe : a rule with pest arch to not allowed "all()" method on Eloquent Model ?

    • @LaravelDaily
      @LaravelDaily  4 วันที่ผ่านมา

      But the same would apply to ->get()->where(), not only all().
      But yeah, maybe something is possible to build via custom Pest arch tests.

  • @ゲンスルー-g2q
    @ゲンスルー-g2q 4 วันที่ผ่านมา +2

    It's time to kindly assert some authority as a Laravel influencer to the rookie.

    • @LaravelDaily
      @LaravelDaily  4 วันที่ผ่านมา +12

      I was trying to not go with authority, rather with helping hand. And I asked Leah's permission before shooting this video.

  • @JamesAutoDude
    @JamesAutoDude 4 วันที่ผ่านมา

    Personally I think all her problems would be solved with utilities lol