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
very helpful video. We hope to produce more videos like this to assist junior developers. The video helps shorten the learning curve for junior developers
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.
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.
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
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 /
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
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)
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.
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!
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
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:
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?
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
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); }
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 :/
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
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.
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()
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
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.
smooth
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
very helpful video. We hope to produce more videos like this to assist junior developers. The video helps shorten the learning curve for junior developers
The $request->validate() function also return an array of validated fields, you can use that if you don't want a separate FormRequest class.
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.
I love your code reviews
me to sir.
I learned a lot about this topic, I hope more code review contents sir!
Thank you for another daily video Sir.
Those code reviews help me to much! Thanks for this content!
me too!
I love this! This is probably the best thing I've come across on TH-cam for learning.
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.
you are great sir, this help us to avoid these mistakes. Thank you!
another bombshell video, my daily routine
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
Nice explanation!🎉
It´s very awesome to sharing your experiences with us. Thank you very much for that.
Thank You So much. This Review is amazing
wow , that was amazing 😍😍 pls keep going this way
good video as always, greetings from Brazil
Thank you, i learn new things everyday with you, thank you very much
Thanks Povilas as always! Keep working!
Everyday I learned new things. Thanks
you are doing grate thing sir! thanks!!
Thank You, very good video as usual.
you are Great man ✨
Thanks for the code review, really learned a lot
thanks from Brazil!
more reviews please ! :)
Great videos. Insightful, to the point. Thanks!
You would need to manually map is_donor from the database to blood_donor from the request
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
I don't know about VS code, I use phpstorm
Very helpful!
For the home route you can just a redirect rather than having it load the view
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 /
Thanks teacher!
Beautiful ❤️
great stuff!
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
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)
What is the Editor and Plugin? awesome
Thanks teacher
Thanks.
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.
What's the difference between put and post
Thank you
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!
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
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:
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?
Do you use any extensions/plugins with phpstorm?
Not really, but I recommend Laravel Idea
I think that project was written by at least 2 different developers. You can tell that because of the inconsistencies pointed out.
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
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);
}
Hello sir, we need a apiato laravel video session
Hello sir, may i know the ext for filling up some form?? Thank you
Fake Filler.
is there a way to request a user re-authentification when he try to modify something important (with jetstream ?) thanks !
Use middleware class.
Laravel confirmed middleware. Which ask for password again and store confirmed session for few minutes.
Great
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
can i send project to review, the project by laravel and laravel-mix vue, vuex, vue route ?
the project is user dashboard wit sanctum api auth
Sorry, currently I have already a long list of projects to review. Maybe in a few months.
@@LaravelDaily ok Thanks a lot for this videos, it's very helpful
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 :/
I don't recommend using shared hosting for any Laravel projects. Learn how to use vps, this is my advice.
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
You can. But, in this case, is_admin is fillable, too.
@@LaravelDaily Oh of course! Great job. Thank you!
what is this IDE please ?
PHPStorm
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.
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()
Share the git link of the code, please.
I don't have a permission to do that, it's not my code.
8:40 bug introduced, $user->is_donor = $request->blood_donor;
blood_donor key must've contained a boolean value.
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
I don't like data 🤣🤣
Thanks teacher