Тёмный

Laravel: Repository Pattern in practice 

Przemysław Przyłucki
Подписаться 5 тыс.
Просмотров 11 тыс.
50% 1

Наука

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 24   
@harshadevapriyankarabandar5456
@harshadevapriyankarabandar5456 Месяц назад
I think controller and service layer is enough for most of the laravel applications. Hence we are re creating all the method in the repository which is already available in the laravel eloquent model, it seems like a repetitive work without any additional benefit. We can just keep our controller clean and pass the business login to service class , then resolve the function my accessing database via eloquent models and then return the result to controller. in that way we can use the laravel already build eloquent powers easily and quickly.
@DailyTechShot
@DailyTechShot 6 месяцев назад
Please people, do not use a repository pattern in Laravel. Laravel has a beautiful active record solution and a repository pattern would only make sense when you would actually want to swap your database implementation, from let's say Mysql to Mongo for example. Do not use 'patterns' for the sake of using them. .
@hydrokat143
@hydrokat143 3 месяца назад
eloquent can switch over databases with some config changes in the database config and/or eloquent model. question is… is switching from sql to nosql or vv a thing?
@Muhammed-nani964
@Muhammed-nani964 Год назад
I think service (action) + DTO is better you may want to create a video on it
@verard0
@verard0 Год назад
really nice video! you covered a lot of info! congrats for your work!
@rahmaabdelaziz4095
@rahmaabdelaziz4095 Год назад
great work
@mohammadjavadrajabloo2711
@mohammadjavadrajabloo2711 2 месяца назад
Good Video!
@user-fx1qh8ml5v
@user-fx1qh8ml5v 6 месяцев назад
Its better to use BlogPost::query()->toBase()->first() instead of BlogPost::first()->toArray(), because in second scenario, laravel convert array from DB to Eloquent, and convert eloquent to array. In first scenario you get raw data without converting
@parumhr1268
@parumhr1268 10 месяцев назад
what are the advantages to implementing the BlogRepositoryInterface as to just injecting the BlogRepository directly in the constructor??
@saaslaravel
@saaslaravel 10 месяцев назад
You have the freedom to change the implementation of the repository i.e you can change persistence layer or move it to a 3rd party without changing how it interacts with the rest of the application
@user-ou5gg7pv4m
@user-ou5gg7pv4m 11 месяцев назад
Hello we made injection on BaseRepository for Model but ı did same things laravel give an error like " Target [Illuminate\Database\Eloquent\Model] is not instantiable while building [App\Http\Controllers\BlogController, App\Repositories\BlogRepository]" when ı make like " $this->app->bind(BlogRepositoryInterface::class,BlogRepository::class);" in AppServiceProvider for solition ı changed this as " $this->app->bind(BlogRepositoryInterface::class,function (){ return new BlogRepository(new Blog()); });" is there any solution ? Thank you for feeds from now ...
@alexz75515
@alexz75515 Год назад
Because this line is very long you can tell that this is an enterprise application... 😆
@GergelyCsermely
@GergelyCsermely Год назад
Hi! I would suggest to use Route::resource
@saaslaravel
@saaslaravel Год назад
Never. I hate those! They decrease visibility for me
@topvova
@topvova Год назад
Why add an extra layer to Eloquent with interfaces and DTOs? This approach only clutters the code and reduces its maintainability.
@saaslaravel
@saaslaravel Год назад
I never use it personally but some of the reasons include decoupling the entity model from the database or organisation and reuse of more complex queries
@impulserr
@impulserr 6 месяцев назад
You can mock it easier for tests and it is cleaner imo. I like repositories for readonly eloquent/queries and services on top of that only if I need some more processing/logic + jobs if u need to update/insert/delete. Personally I think it is much better then throwing all to services.
@user-uh6qn1ef1d
@user-uh6qn1ef1d 3 месяца назад
I personally do controller
@himasami2200
@himasami2200 Год назад
can u please give me a source code of this video to study?
@saaslaravel
@saaslaravel Год назад
I don't have source code for it unfortunately. Will be doing that for any videos going forward 😄
@haingocduong5145
@haingocduong5145 5 месяцев назад
Eloquent is a Repository . Don't use Repository Pattern if your Repository get data by Eloquent . it's meaningless
@user-ge6pt5lp9u
@user-ge6pt5lp9u Месяц назад
Thnx for approach guide. But could you not speed up the words partially within eat the volume at the end of phrase.. 😅
@user-fx1qh8ml5v
@user-fx1qh8ml5v 6 месяцев назад
Its better to use BlogPost::query()->toBase()->first() instead of BlogPost::first()->toArray(), because in second scenario, laravel convert array from DB to Eloquent, and convert eloquent to array. In first scenario you get raw data without converting
Далее
Laravel's secret weapon: macros (watch me code)
23:46
Laravel Code Review: Why NOT Use Repository Pattern?
14:21
Ik Heb Aardbeien Gemaakt Van Kip🍓🐔😋
00:41
Why Don't We Have A Laravel For JavaScript?
12:36
Просмотров 95 тыс.
Refactoring to action pipelines in Laravel
1:25:03
Просмотров 9 тыс.
Laravel + Service Pattern + DTOs = ❤️❤️❤️
17:52
Junior Code Review: Cleaning Up Laravel CRUD
14:54
Просмотров 68 тыс.
WOW! Laravel's pipeline pattern is AWESOME
20:39
Просмотров 12 тыс.
Laravel 6 Advanced - e7 - Repository Pattern
23:24
Просмотров 103 тыс.
Последствия блокировки YouTube
25:35
MSI GAMING BLACK SCREEN / STUCK ON BOOT LED
1:00
Просмотров 4,4 млн