File tree Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Support \Facades \Schema ;
66use Illuminate \Support \ServiceProvider ;
7- use App \Repositories \Demo \DemoRepository ;
8- use App \Repositories \Demo \EloquentDemoRepository ;
97
108class AppServiceProvider extends ServiceProvider
119{
@@ -14,9 +12,7 @@ class AppServiceProvider extends ServiceProvider
1412 */
1513 public function register (): void
1614 {
17- $ this ->app ->bind (DemoRepository::class, function () {
18- return new EloquentDemoRepository ();
19- });
15+
2016 }
2117
2218 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Providers ;
4+
5+ use Illuminate \Support \ServiceProvider ;
6+
7+ class RepositoryServiceProvider extends ServiceProvider
8+ {
9+ /**
10+ * Register any services.
11+ */
12+ public function register (): void
13+ {
14+ $ bindings = [
15+ \App \Repositories \Demo \DemoRepository::class => \App \Repositories \Demo \EloquentDemoRepository::class,
16+ ];
17+
18+ foreach ($ bindings as $ abstract => $ concrete ) {
19+ $ this ->app ->bind ($ abstract , $ concrete );
20+ }
21+ }
22+
23+ /**
24+ * Bootstrap any services.
25+ */
26+ public function boot (): void
27+ {
28+ //
29+ }
30+ }
Original file line number Diff line number Diff line change 168168 // App\Providers\BroadcastServiceProvider::class,
169169 App \Providers \EventServiceProvider::class,
170170 App \Providers \RouteServiceProvider::class,
171+
172+ /**
173+ * Repository service provider.
174+ */
175+ \App \Providers \RepositoryServiceProvider::class,
176+
171177 ])->toArray (),
172178
173179 /*
You can’t perform that action at this time.
0 commit comments