Junior Code Review: Better Routes, CRUDs and Validation

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

КОМЕНТАРІ • 86

  • @randomguy5922
    @randomguy5922 3 роки тому +12

    It's a very tedious task to review someone's code....thanks sir for bringing this great CODE REVIEW content.
    This actually helps us to rectify our mistakes because we also do a lot of these bad coding practices

  • @jordysinke
    @jordysinke 3 роки тому +13

    The $request->validate() function also return an array of validated fields, you can use that if you don't want a separate FormRequest class.

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

      He knows that, but he typically strongly pushes for form requests because he likes small files. I personally think that separate form request objects lower cohesion and increase coupling, and aren't my preference in most cases.

  • @JSONFX
    @JSONFX 3 роки тому +12

    This is by far the best code reviews i've seen in laravel here on youtube. Well done! I'll be watching more videos and learn more.

  • @grzesiekb9142
    @grzesiekb9142 2 роки тому +2

    I love your code reviews

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

    Thank you for another daily video Sir.

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

    Those code reviews help me to much! Thanks for this content!

  • @venzolarte7023
    @venzolarte7023 9 місяців тому

    I learned a lot about this topic, I hope more code review contents sir!

  • @mahmoudelsherbeny6003
    @mahmoudelsherbeny6003 2 роки тому +1

    you are great sir, this help us to avoid these mistakes. Thank you!

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

    I love this! This is probably the best thing I've come across on UA-cam for learning.

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

    another bombshell video, my daily routine

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

    you are doing grate thing sir! thanks!!

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

    It´s very awesome to sharing your experiences with us. Thank you very much for that.

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

    Nice explanation!🎉

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

    Thank you, i learn new things everyday with you, thank you very much

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

    Amazing Video Sir! I’m trying to climb to intermediate level and playing around with packages, and your video truly amazed me! I have learnt a lot from u.

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

    yo man, your seniors tips are awesome, i realy like when the code it transformed in more readeble. i will implements all what i have learned today

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

    Everyday I learned new things. Thanks

  • @belce1982
    @belce1982 2 роки тому

    Thanks Povilas as always! Keep working!

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

    Thank You, very good video as usual.

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

    good video as always, greetings from Brazil

  • @abdullah.alhabal
    @abdullah.alhabal 2 місяці тому

    you are Great man ✨

  • @user-vt6ix2pi2d
    @user-vt6ix2pi2d 3 роки тому

    wow , that was amazing 😍😍 pls keep going this way

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

    Thanks for the code review, really learned a lot

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

    thanks from Brazil!

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

    Great videos. Insightful, to the point. Thanks!

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

    more reviews please ! :)

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

    For the home route you can just a redirect rather than having it load the view

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

      Actually I bet it's for a different reason. I bet it's because logging in directs you to /home by default, and the correct solution there would be to configure the Auth portion of the code to default its home page to /

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

    You would need to manually map is_donor from the database to blood_donor from the request

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

    Thanks teacher!

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

    Thanks teacher

  • @_xplore
    @_xplore 2 роки тому

    Thanks.

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

    Very helpful!

  • @JouvaMoufette
    @JouvaMoufette 3 роки тому +4

    I'm not a betting man, but I feel like the /home URL exists because that's the default for when you log in, and the correct solution there would be to configure it to use the / path instead.
    I can't think of any other reason why the path for /home exists

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

      I agree with you. Do you agree with me? There are 2 routes / login / register for non-user authentication. If there are sign in and sign up forms on one page, then it is correct to do the path / But if they are divided into separate pages / login, / register then what will the path / be? You need to redirect when entering the site along the path to / to / login (aliase / and /login)

  • @1234matthewjohnson
    @1234matthewjohnson 3 роки тому

    great stuff!

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

    Thank you

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

    Beautiful ❤️

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

    Hey Laravel Daily, this videos are so useful!, they help me a lot. What IDE and extensions (if this is the case) do you use to develop with laravel (backend-api). My VS Code doesn't autocomplete anything

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

      I don't know about VS code, I use phpstorm

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

    7:24 personally i don't like it, it's better to pass variables from controller into the view. Using auth()->user() in blade file causes uncessary function calls, as well it adds unnecessary logic(of getting current authenticated user) to view - if there is any method calls in views, especially like chained calls then i think it's too complex.

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

    Instead of looping the errors in the blade to see them, you can also check them in the debug bar in the Sessions section under errors

  • @javieru5871
    @javieru5871 2 роки тому

    I think that project was written by at least 2 different developers. You can tell that because of the inconsistencies pointed out.

  • @EmonKhan-sr5zg
    @EmonKhan-sr5zg 3 роки тому

    In profile update - it can be more shorter with all() method.
    Just need to undeclare those protected property (like: is_admin) on the $fillable property or define in $guarded as a same. Then we can use $request->all() to save the model.
    Tip: whenever we need to update $guarded property, we can get the object $user = auth()->user() then $user->is_admin = 1 then $user->save()

  • @yungifez
    @yungifez 2 роки тому

    What's the difference between put and post

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

    sir please can u make a video on Auth customization which is inbuilt in laravel as i work in api development and i wanted to customize Auth() of laravel or any suggestion please

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

    Hello sir, we need a apiato laravel video session

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

    Sir, how to avoid, FormRequest and middleware conflict, when in Middleware class I get error that FormRequest class does not exist. I use store method which validates from FormRequest class and also is protected by middleware class which use basic Request class. How fix that issue?

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

    Not relate to Laravel but (bootstrap stuff)... he is using primary color in all button. Primary should indicate main action in the page and all other button shold be secondary. I prefere to use success color to indicate buttons that add something.

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

    What is the Editor and Plugin? awesome

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

    Hi sir , Is it good practice to use static method in laravel model file like below
    public static function question($paper_id)
    {
    return self::where('paper_id',$paper_id);
    }

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

    Great

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

    these series help a lot, excellent work as always. I wanted to ask about what approach you consider best when displaying different columns of a table when using laravel as API, for example when I extract a single post from the database I want to show all the fields, but when I request all of them, I only want to extract 2 fields. In this case it is better to create two separate resources or specify the fields in the corresponding method? thanks a lot!

    • @Jose-oz1by
      @Jose-oz1by 3 роки тому

      You can use pluck function in collections
      if your collections has 3 field like: name, age, birth_date and You only want to retrieve name
      you can make somethign like this:
      $collection->pluck('name');
      (fake example: User::get()->pluck('name', 'anotherfield);)
      check laravel documentation :)
      laravel.com/docs/8.x/collections#method-pluck

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

      Using the query scopes sounds like it would solve your problem. Instead of simply calling Model::all();, you could also write: Model::query()->select(‘field_1’, ‘field_2’)->get();. It will solve your problem and also increase the speed the records are loaded.
      You could refactor these select statements to a local or global scope (see: laravel.com/docs/8.x/eloquent#query-scopes ).
      You could create a scope for when you only want to extract the two fields for a single post, add them to your Eloquent Model class (or create a separate class like so, for example a user Eloquent model):
      public function newEloquentBuilder($query): UserQueryBuilder
      {
      return new UserQueryBuilder($query);
      }
      Example query scope for users:

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

    Hello sir, may i know the ext for filling up some form?? Thank you

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

    Do you use any extensions/plugins with phpstorm?

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

      Not really, but I recommend Laravel Idea

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

    Hello, first of all I would like to congratulate you for the videos and tips about laravel. I really appreciate that.
    I have a doubt. In controller of update profile, when we have the model $fillable field setted, we can't just pass the request to update method? Like ```auth()->user()->update($request->all())``` safely? The fillable attribute in model doesn't grant that none unspectable fields like "is_admin" will be injected?
    Thanks a lot

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

      You can. But, in this case, is_admin is fillable, too.

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

      @@LaravelDaily Oh of course! Great job. Thank you!

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

    is there a way to request a user re-authentification when he try to modify something important (with jetstream ?) thanks !

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

      Use middleware class.

    • @AbrarAhmad-mz8vl
      @AbrarAhmad-mz8vl 3 роки тому +3

      Laravel confirmed middleware. Which ask for password again and store confirmed session for few minutes.

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

    I have a request for a video! How to deploy laravel on plesk. Keep struggling doing this. Cant migrste the database and I dont want to switch to a vps because i dont know how to configure a Mailserver :/

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

      I don't recommend using shared hosting for any Laravel projects. Learn how to use vps, this is my advice.

  • @47Lancelot
    @47Lancelot 3 роки тому +3

    8:40 bug introduced, $user->is_donor = $request->blood_donor;

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

      blood_donor key must've contained a boolean value.

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

    can i send project to review, the project by laravel and laravel-mix vue, vuex, vue route ?

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

      the project is user dashboard wit sanctum api auth

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

      Sorry, currently I have already a long list of projects to review. Maybe in a few months.

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

      @@LaravelDaily ok Thanks a lot for this videos, it's very helpful

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

    Share the git link of the code, please.

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

      I don't have a permission to do that, it's not my code.

  • @info-pedia
    @info-pedia Рік тому

    what is this IDE please ?

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

    Please Sir Laravel Daily make a video course Chat. Laravel8 + Vue 3 or React + pusher (websockets) + Restfull api + jwt etc
    I would take it for 200 dollars (Or any other price) or more. I want to become a developer and master everything
    Template chatvia -> themeforest

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

    I don't like data 🤣🤣

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

    Thanks teacher