Livewire Code Review: Likeable Component - 10 Improvements

preview_player
Показать описание
This is a code review of a Livewire component, which is actually optimization of the PHP class. Will you join me?

00:00 Introducing Component
01:31 Code Overview
03:01 Undefined Class Properties
03:51 Dynamic Class Names
05:45 Unnecessary Variable/Query
07:30 Formatting the Code
07:47 Config Default Values
09:15 Public or Private Methods
10:40 Wait, THAT many DB Queries??
15:17 Remove Duplicate Methods
15:57 Eloquent create() vs save()
17:07 Remove Even More Methods

Related links:

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

I found out about using dynamic class names by source diving the Model class. Another cool thing you can do is using dynamic variable names which is kinda weird but helps if you found yourself in a scenario where dynamic variables would be helpful.

daleryanaldover
Автор

I think setting up the initial like or dislike is the best way to reduce the query even more, that's the way i did it in some of my project

ilhamfajriumar
Автор

14:50 Could we just query all the likes(that we need of course) from the parent component and then pass them to each button component. This would result in only one query and remove query to db from component itself?

usanzadunje
Автор

I prefer to pass the model itself instead only the classname and id, so i dont need to query to database to get the data, cuz its already there.

rahmanramsi
Автор

I missed the yesterday 48 hour videos :(

krishnanarasimha
Автор

King Stalker
0 seconds ago
Is there anyway to make the blade syntaxes autocomplete for you for the live wire things also can it not look so white I see spatie permissions blade does the same thing for example I say @role(autocomete your role ) and looks like a normal blade syntax I hope I make sense

kingstalker
Автор

In the next video "code review" i want to share my github repository and review it. How i can send you email ?

Ghost-hzdy
Автор

I have a question.
1. livewire always render full page on request. Is there any way to render only specific div. without using wire:ignore.
2. I have a bootstrap form wizard when ever make some request the wizard steps become inactive or may go to first step if we are on other step. currently i'm handling it making the steps dynamic to check which step is active or not it works but still flicker. do you have any idea, advice to manage state. Thank you.

abdulrehmandar
Автор

make one laravel project from scratch....not like this

ahmednisar
welcome to shbcf.ru