@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'oauth-clients'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'oauth-clients'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'oauth-clients'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'oauth-clients'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('oauth-clients', 'Database/Migrations', 'app')); |
|
20 | - $this->loadFactoriesFrom(module_path('oauth-clients', 'Database/Factories', 'app')); |
|
21 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('oauth-clients', 'Database/Migrations', 'app')); |
|
20 | + $this->loadFactoriesFrom(module_path('oauth-clients', 'Database/Factories', 'app')); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Register the module services. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function register() |
|
29 | - { |
|
30 | - $this->app->register(RouteServiceProvider::class); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + $this->app->register(RouteServiceProvider::class); |
|
31 | + } |
|
32 | 32 | } |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\OauthClients\OauthClient::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'user_id' => $faker->randomDigit(), |
|
6 | - 'name' => $faker->name(), |
|
7 | - 'secret' => \Illuminate\Support\Str::random(40), |
|
8 | - 'redirect' => $faker->url(), |
|
9 | - 'personal_access_client' => 0, |
|
10 | - 'password_client' => 0, |
|
11 | - 'revoked' => $faker->boolean(), |
|
12 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
13 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
14 | - ]; |
|
4 | + return [ |
|
5 | + 'user_id' => $faker->randomDigit(), |
|
6 | + 'name' => $faker->name(), |
|
7 | + 'secret' => \Illuminate\Support\Str::random(40), |
|
8 | + 'redirect' => $faker->url(), |
|
9 | + 'personal_access_client' => 0, |
|
10 | + 'password_client' => 0, |
|
11 | + 'revoked' => $faker->boolean(), |
|
12 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
13 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
14 | + ]; |
|
15 | 15 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\OauthClients\OauthClient::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\OauthClients\OauthClient::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'user_id' => $faker->randomDigit(), |
6 | 6 | 'name' => $faker->name(), |
@@ -6,58 +6,58 @@ |
||
6 | 6 | |
7 | 7 | class OauthClientsTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to oauthClients table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * OauthClients model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'oauthClient', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'find', |
|
32 | - 'model' => 'oauthClient', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'insert', |
|
38 | - 'model' => 'oauthClient', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'oauthClient', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'revoke', |
|
50 | - 'model' => 'oauthClient', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'unRevoke', |
|
56 | - 'model' => 'oauthClient', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - ] |
|
61 | - ); |
|
62 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to oauthClients table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * OauthClients model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'oauthClient', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'find', |
|
32 | + 'model' => 'oauthClient', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'insert', |
|
38 | + 'model' => 'oauthClient', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'oauthClient', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'revoke', |
|
50 | + 'model' => 'oauthClient', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'unRevoke', |
|
56 | + 'model' => 'oauthClient', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + ] |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class OauthClientsDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(OauthClientsTableSeeder::class); |
|
18 | - $this->call(AssignRelationsSeeder::class); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(OauthClientsTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_auth_codes', function(Blueprint $table) { |
|
17 | 17 | $table->string('id', 100)->primary(); |
18 | 18 | $table->integer('user_id'); |
19 | 19 | $table->integer('client_id'); |
@@ -6,33 +6,33 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthAuthCodesTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->integer('user_id'); |
|
19 | - $table->integer('client_id'); |
|
20 | - $table->text('scopes')->nullable(); |
|
21 | - $table->boolean('revoked'); |
|
22 | - $table->dateTime('expires_at')->nullable(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->integer('user_id'); |
|
19 | + $table->integer('client_id'); |
|
20 | + $table->text('scopes')->nullable(); |
|
21 | + $table->boolean('revoked'); |
|
22 | + $table->dateTime('expires_at')->nullable(); |
|
23 | 23 | |
24 | - $table->foreign('user_id')->references('id')->on('users'); |
|
25 | - $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
26 | - }); |
|
27 | - } |
|
24 | + $table->foreign('user_id')->references('id')->on('users'); |
|
25 | + $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
26 | + }); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Reverse the migrations. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function down() |
|
35 | - { |
|
36 | - Schema::drop('oauth_auth_codes'); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Reverse the migrations. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function down() |
|
35 | + { |
|
36 | + Schema::drop('oauth_auth_codes'); |
|
37 | + } |
|
38 | 38 | } |
@@ -7,28 +7,28 @@ |
||
7 | 7 | |
8 | 8 | class OauthClient extends JsonResource |
9 | 9 | { |
10 | - /** |
|
11 | - * Transform the resource into an array. |
|
12 | - * |
|
13 | - * @param Request $request |
|
14 | - * @return array |
|
15 | - */ |
|
16 | - public function toArray($request) |
|
17 | - { |
|
18 | - if (! $this->resource) { |
|
19 | - return []; |
|
20 | - } |
|
10 | + /** |
|
11 | + * Transform the resource into an array. |
|
12 | + * |
|
13 | + * @param Request $request |
|
14 | + * @return array |
|
15 | + */ |
|
16 | + public function toArray($request) |
|
17 | + { |
|
18 | + if (! $this->resource) { |
|
19 | + return []; |
|
20 | + } |
|
21 | 21 | |
22 | - return [ |
|
23 | - 'id' => $this->id, |
|
24 | - 'name' => $this->name, |
|
25 | - 'redirect' => $this->redirect, |
|
26 | - 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | - 'personalAccessClient' => $this->personal_access_client, |
|
28 | - 'passwordClient' => $this->password_client, |
|
29 | - 'revoked' => $this->revoked, |
|
30 | - 'created_at' => $this->created_at, |
|
31 | - 'updated_at' => $this->updated_at, |
|
32 | - ]; |
|
33 | - } |
|
22 | + return [ |
|
23 | + 'id' => $this->id, |
|
24 | + 'name' => $this->name, |
|
25 | + 'redirect' => $this->redirect, |
|
26 | + 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | + 'personalAccessClient' => $this->personal_access_client, |
|
28 | + 'passwordClient' => $this->password_client, |
|
29 | + 'revoked' => $this->revoked, |
|
30 | + 'created_at' => $this->created_at, |
|
31 | + 'updated_at' => $this->updated_at, |
|
32 | + ]; |
|
33 | + } |
|
34 | 34 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function toArray($request) |
19 | 19 | { |
20 | - if (! $this->resource) { |
|
20 | + if ( ! $this->resource) { |
|
21 | 21 | return []; |
22 | 22 | } |
23 | 23 |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class InsertOauthClient extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'required|max:255', |
|
28 | - 'redirect' => 'required|url', |
|
29 | - 'user_id' => 'required|exists:users,id', |
|
30 | - 'revoked' => 'boolean' |
|
31 | - ]; |
|
32 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'required|max:255', |
|
28 | + 'redirect' => 'required|url', |
|
29 | + 'user_id' => 'required|exists:users,id', |
|
30 | + 'revoked' => 'boolean' |
|
31 | + ]; |
|
32 | + } |
|
33 | 33 | } |
@@ -6,29 +6,29 @@ |
||
6 | 6 | |
7 | 7 | class UpdateOauthClient extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'id' => 'required|exists:oauth_clients,id', |
|
28 | - 'name' => 'required|max:255', |
|
29 | - 'redirect' => 'required|url', |
|
30 | - 'user_id' => 'required|exists:users,id', |
|
31 | - 'revoked' => 'boolean' |
|
32 | - ]; |
|
33 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'id' => 'required|exists:oauth_clients,id', |
|
28 | + 'name' => 'required|max:255', |
|
29 | + 'redirect' => 'required|url', |
|
30 | + 'user_id' => 'required|exists:users,id', |
|
31 | + 'revoked' => 'boolean' |
|
32 | + ]; |
|
33 | + } |
|
34 | 34 | } |
@@ -5,73 +5,73 @@ |
||
5 | 5 | |
6 | 6 | class NotificationRepository extends BaseRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param Notification $model |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(Notification $model) |
|
15 | - { |
|
16 | - parent::__construct($model); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param Notification $model |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(Notification $model) |
|
15 | + { |
|
16 | + parent::__construct($model); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Retrieve all notifications of the logged in user. |
|
21 | - * |
|
22 | - * @param integer $perPage |
|
23 | - * @return Collection |
|
24 | - */ |
|
25 | - public function my($perPage) |
|
26 | - { |
|
27 | - return \Auth::user()->notifications()->paginate($perPage); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Retrieve all notifications of the logged in user. |
|
21 | + * |
|
22 | + * @param integer $perPage |
|
23 | + * @return Collection |
|
24 | + */ |
|
25 | + public function my($perPage) |
|
26 | + { |
|
27 | + return \Auth::user()->notifications()->paginate($perPage); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Retrieve unread notifications of the logged in user. |
|
32 | - * |
|
33 | - * @param integer $perPage |
|
34 | - * @return Collection |
|
35 | - */ |
|
36 | - public function unread($perPage) |
|
37 | - { |
|
38 | - return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
39 | - } |
|
30 | + /** |
|
31 | + * Retrieve unread notifications of the logged in user. |
|
32 | + * |
|
33 | + * @param integer $perPage |
|
34 | + * @return Collection |
|
35 | + */ |
|
36 | + public function unread($perPage) |
|
37 | + { |
|
38 | + return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Mark the notification as read. |
|
43 | - * |
|
44 | - * @param integer $id |
|
45 | - * @return object |
|
46 | - */ |
|
47 | - public function markAsRead($id) |
|
48 | - { |
|
49 | - if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) { |
|
50 | - $notification->markAsRead(); |
|
51 | - } |
|
52 | - } |
|
41 | + /** |
|
42 | + * Mark the notification as read. |
|
43 | + * |
|
44 | + * @param integer $id |
|
45 | + * @return object |
|
46 | + */ |
|
47 | + public function markAsRead($id) |
|
48 | + { |
|
49 | + if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) { |
|
50 | + $notification->markAsRead(); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Mark all notifications as read. |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function markAllAsRead() |
|
60 | - { |
|
61 | - \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Mark all notifications as read. |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function markAllAsRead() |
|
60 | + { |
|
61 | + \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Notify th given user with the given notification. |
|
66 | - * |
|
67 | - * @param collection $users |
|
68 | - * @param string $notification |
|
69 | - * @param object $notificationData |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function notify($users, $notification, $notificationData = false) |
|
73 | - { |
|
74 | - $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
75 | - \Notification::send($users, new $notification($notificationData)); |
|
76 | - } |
|
64 | + /** |
|
65 | + * Notify th given user with the given notification. |
|
66 | + * |
|
67 | + * @param collection $users |
|
68 | + * @param string $notification |
|
69 | + * @param object $notificationData |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function notify($users, $notification, $notificationData = false) |
|
73 | + { |
|
74 | + $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
75 | + \Notification::send($users, new $notification($notificationData)); |
|
76 | + } |
|
77 | 77 | } |