Laravel Code Review: SQL Queries and Better Naming

preview_player
Показать описание
Reviewing a Livewire component that can be improved with naming things, removing the comments, and optimizing Eloquent queries.

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Комментарии
Автор

Regarding the last point made in this video about the if/else.. You can keep most of the structure the same but move the $merged->keyBy(...) assignment line outside of the if/else block since either way $merged will be assigned.

You could also shorten the line to $this->chart =$merged->keyBy(fn (array $item) => $item['pivot']['tooth_id']); Because the "$key" variable isn't used anywhere in the closure and while it's personal preference whether to use arrow funcs or not, this is a good candidate to use them over lambdas.

erichansen
Автор

Kind of breaking the single responsibility principle with the long method. But generally some very good advice for beginners.

jetmirhaxhisefa
Автор

At @2:14 you renamed the variable wrongly. This line checks if the current appointment is the patient's first appointment. I guess too many comments makes the code less understandable :D

wgblondel
Автор

Those if-else blocks break my heart. I hate them a lot. match() with extracted method calls will make the code extremely readable in my opinion.

bulent
Автор

maybe the comment above each code used for copilot generate code.

rizkiakbar
Автор

At least One code review in week please

shubhamsahuSD
Автор

I think the developer generate the comments by AI

ahmedlist