-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAppServiceProvider.php
81 lines (69 loc) · 2.47 KB
/
AppServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use TinnyApi\Contracts\UserRepository;
use TinnyApi\DBConnection\MySQLConnectionFactory as MysqlConnection;
use TinnyApi\DBConnection\SQLiteConnectionFactory as SQLiteConnection;
use TinnyApi\Models\UserModel;
use TinnyApi\Notifications\VerifyEmailNotification;
use TinnyApi\Repositories\UserEloquentRepository;
use TinnyApi\Requests\PasswordUpdateRequest;
use TinnyApi\Requests\UserUpdateRequest;
use TinnyApi\Rules\CurrentPasswordRule;
use TinnyApi\Rules\WeakPasswordRule;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->registerAllServices();
}
private function registerAllServices()
{
$this->app->singleton(MysqlConnection::class, function ($app) {
return new MysqlConnection($app['db']);
});
$this->app->singleton(SQLiteConnection::class, function ($app) {
return new SQLiteConnection($app['db']);
});
$this->app->singleton(UserRepository::class, function ($app) {
return new UserEloquentRepository(
new UserModel(),
$app['cache.store'],
$app['auth.driver'],
$app['events']
);
});
$this->app->singleton(WeakPasswordRule::class, function ($app) {
return new WeakPasswordRule($app['cache.store']);
});
$this->app->singleton(CurrentPasswordRule::class, function ($app) {
return new CurrentPasswordRule($app['hash'], $app['auth.driver']);
});
$this->app->singleton(PasswordUpdateRequest::class, function ($app) {
return tap(new PasswordUpdateRequest(), function ($passwordUpdateRequest) use ($app) {
$passwordUpdateRequest->setCurrentPasswordRuleInstance($app[CurrentPasswordRule::class]);
$passwordUpdateRequest->setWeakPasswordRuleInstance($app[WeakPasswordRule::class]);
});
});
$this->app->singleton(UserUpdateRequest::class, function () {
return new UserUpdateRequest();
});
$this->app->singleton(VerifyEmailNotification::class, function ($app) {
return new VerifyEmailNotification($app['config']);
});
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}