Junior Laravel Developer Code Review - Reviewing Routes, Migrations, Models & Controllers in Laravel

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

КОМЕНТАРІ • 62

  • @codewithdary
    @codewithdary  Рік тому +7

    Do you think I should create more code review tutorials? Let me know!
    Follow me or subscribe to my newsletter to get notified when my course is released:
    - Twitter: twitter.com/codewithdary
    - Instagram: instagram.com/codewithdary/
    - Blog: blog.codewithdary.com/

  • @jackelofnar
    @jackelofnar Рік тому +8

    Hi Dary, I hope you continue with this series as someone who is still learning Laravel you gave alotof great tips.

    • @codewithdary
      @codewithdary  Рік тому +2

      Thank you Jack! If the video performs well (and it's doing right now) I will definitely continue on making more of these!

  • @Tux0xFF
    @Tux0xFF Рік тому +1

    This channel is a goldmine, you dont get to see these type of reviews and content unless its premium content, glad that i found it

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

      Thank you so much for the compliments, means the world to me

  • @baochungpro1996
    @baochungpro1996 Рік тому +3

    Great, please continue with this kinda series. Thanks so much, Dary.

  • @petermwangi7274
    @petermwangi7274 Рік тому +2

    Much informative Dary. Definitely looking to more of your code review tutorials.

  • @basharumar2912
    @basharumar2912 Рік тому +1

    promise fulfilled! Thank you mr Dary and looking forward to having more tutorials like this.

    • @codewithdary
      @codewithdary  Рік тому +1

      Appreciate the kind words Bashar. If it performs well, I will definitely continue on making content like this!

  • @waleedgrt4904
    @waleedgrt4904 Рік тому +2

    Hey Dary, At 22:33, the "validated" method is more convenient than the "only" method.

    • @codewithdary
      @codewithdary  Рік тому +1

      Both options work fine, there isn't a right or wrong right here, I'm just not really a fan of it. I prefer to explicitly define and insert data into the database. Completely fine using the other method.

  • @GavinKimpson
    @GavinKimpson Рік тому +1

    Dude your videos are great, you'll be at 100k subscribers in no time!

  • @b3rking
    @b3rking Рік тому +1

    Hello dary, thanks for the review and for the corrections, i'll make sure to apply them in my next versions. Again thanks a lot, it means a lot. Keep it up!

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

      Appreciate it, keep on going with the good work!!

  • @grzesiekb9142
    @grzesiekb9142 Рік тому +2

    $request->validated() returns only validated fields. You can safly use $model->update( $request->validated() ) i think...

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

      That is correct. The source code will not get into the method if the validation passes, so it does not really matter whether you use the $request validated or the values directly.

  • @user-rv5rm1yl1g
    @user-rv5rm1yl1g 10 місяців тому +1

    That's a good video!
    But I have a few points that concerns me.
    If you injected FormRequest class instead of general Request, then you don't need to call "$request->validated()" to trigger validation. It would be taken care of by Laravel itself.
    I think it's not a good point to use "auth()" helper inside any models function - it seem not obvious and has it's own issues. I would use "$this" instead. For me it seem more convenient.

    • @codewithdary
      @codewithdary  10 місяців тому

      Yes, that is true in Laravel. If you inject a FormRequest class instead of the general Request class, you don't need to call "$request->validated()" to trigger validation. Laravel automatically handles the validation process when using FormRequest classes.

  • @basharumar2912
    @basharumar2912 Рік тому +1

    i hope one day you will teach us more about the difference between policies and guardes,listeners and observers etc.

    • @codewithdary
      @codewithdary  Рік тому +1

      Will do in the future!!

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

      @avfr Observers are simply listeners for model events. You can't choose to use one or the other.
      You also cannot manually fire model events from a controller, since they're internally fired by eloquent.

  • @ricardozapanta6656
    @ricardozapanta6656 3 місяці тому

    Hi Dary what extension do you use to see what type of the value needed inside the parameters
    ex: $table->string(column: 'extension');
    the "column""

  • @abukhalid5890
    @abukhalid5890 Рік тому +1

    putting $guarded=[] (empty array) in the model is same as $fillable=[..all request keys here..] and i think you cant put both of these two variables in the same model

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

      I'm pretty sure you can't because these two properties are used to specify which attributes are mass assignable and which are not, respectively. Well, you technically can, but Laravel will prioritize $guarded and ignore $fillable, which could lead to unexpected behavior in your application.

  • @ramzibenssaci2007
    @ramzibenssaci2007 7 місяців тому +1

    thank you dary
    i have simple question why you sometimes use ->value
    and sometimes not
    i means in enum

    • @codewithdary
      @codewithdary  7 місяців тому

      The ->value method is used to retrieve the underlying value of an enum instance. Enums in Laravel are implemented as objects, and ->value allows you to access the actual value stored within the enum rather than the enum object itself!

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

    at 8:45, how your methods are showing key like
    $table->string(column: "something")
    which extension you are using to show "column" thing?

  • @basharumar2912
    @basharumar2912 Рік тому +1

    what is the difference between using foreign or foreignID and which is better?

    • @codewithdary
      @codewithdary  Рік тому +1

      The main difference between the two methods is that foreignId() is a shorthand method that automatically creates a column with an unsigned big integer data type and adds the foreign key constraint to that column. This can simplify the syntax of creating a foreign key constraint.

  • @igerardogc
    @igerardogc Рік тому +1

    What theme, font and spacing are u using? Nice video

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

      Theme: SynthWave 84 (Material)
      Font: Monaco
      Line height: 1.4

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

    brilliant video 👏

    • @codewithdary
      @codewithdary  Рік тому +1

      Appreciate it David, especially coming from you!

  • @pauliusjankauskas8028
    @pauliusjankauskas8028 Рік тому +1

    Why do need $request->validated() in controller since it returns validated data from request? Doesn't validation happen automatically?

    • @codewithdary
      @codewithdary  Рік тому +1

      That works too, just not a fan of using so many things behind the scenes :)

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

      Quick add on btw; I'm reviewing code how I should do it, not saying that it's the best way, just my way.

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

      Yap, there is no best way to do it. Need to make a choice from many ways for particual situation.

    • @pauliusjankauskas8028
      @pauliusjankauskas8028 Рік тому +2

      Just was wondering if didn't make a typo, because as i knew $request->validated() returns only validated data from a request and not do validation it self. For validation, i was using $request->validate().

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

      @@codewithdary If I understand correctly validation as a formrequest then the data is always validated behind the scenes. When you use request->validated() then you only return validated data but you don't assign it anywhere. It makes no sense to me to use this method in your example.

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

    Amazing video thanks

  • @REAZNx
    @REAZNx Рік тому +1

    6:22 Locale is pronounced “low-kal” 🙂

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

      Thank you Lewis. Sounds like low-kal-ories 😜

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

    Is there really such a method as `required` on the ColumnDefinition? Never heard of it 🤔

    • @codewithdary
      @codewithdary  Рік тому +1

      Whoops no, I was a bit mixed-up with another framework, sorry for that!

  • @tharakadoo
    @tharakadoo Рік тому +1

    Hey Dary big fan

  • @karlson2804
    @karlson2804 Рік тому +1

    Wery nice👍🫡