Completed
Push — master ( a7be99...859bad )
by Sherif
02:52
created
src/Modules/V1/Notifications/ModelObservers/NotificationObserver.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@
 block discarded – undo
5 5
  */
6 6
 class NotificationObserver {
7 7
 
8
-    public function saving($model)
9
-    {
10
-        //
11
-    }
12
-
13
-    public function saved($model)
14
-    {
15
-        //
16
-    }
17
-
18
-    public function creating($model)
19
-    {
20
-        //
21
-    }
22
-
23
-    public function created($model)
24
-    {
25
-        //
26
-    }
27
-
28
-    public function updating($model)
29
-    {
30
-        //
31
-    }
32
-
33
-    public function updated($model)
34
-    {
35
-        //
36
-    }
37
-
38
-    public function deleting($model)
39
-    {
40
-        //
41
-    }
42
-
43
-    public function deleted($model)
44
-    {
45
-        //
46
-    }
47
-
48
-    public function restoring($model)
49
-    {
50
-        //
51
-    }
52
-
53
-    public function restored($model)
54
-    {
55
-        //
56
-    }
8
+	public function saving($model)
9
+	{
10
+		//
11
+	}
12
+
13
+	public function saved($model)
14
+	{
15
+		//
16
+	}
17
+
18
+	public function creating($model)
19
+	{
20
+		//
21
+	}
22
+
23
+	public function created($model)
24
+	{
25
+		//
26
+	}
27
+
28
+	public function updating($model)
29
+	{
30
+		//
31
+	}
32
+
33
+	public function updated($model)
34
+	{
35
+		//
36
+	}
37
+
38
+	public function deleting($model)
39
+	{
40
+		//
41
+	}
42
+
43
+	public function deleted($model)
44
+	{
45
+		//
46
+	}
47
+
48
+	public function restoring($model)
49
+	{
50
+		//
51
+	}
52
+
53
+	public function restored($model)
54
+	{
55
+		//
56
+	}
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Console/Commands/MakeNotificationsCommand.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -4,65 +4,65 @@
 block discarded – undo
4 4
 
5 5
 class MakeNotificationsCommand extends GeneratorCommand
6 6
 {
7
-    /**
8
-     * The name and signature of the console command.
9
-     *
10
-     * @var string
11
-     */
12
-    protected $signature = 'make:module:notification
7
+	/**
8
+	 * The name and signature of the console command.
9
+	 *
10
+	 * @var string
11
+	 */
12
+	protected $signature = 'make:module:notification
13 13
         {name : The name of the notification class.}';
14
-    /**
15
-     * The console command description.
16
-     *
17
-     * @var string
18
-     */
19
-    protected $description = 'Create a new module notification class';
20
-    /**
21
-     * String to store the command type.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $type = 'Module notification';
26
-    /**
27
-     * Get the stub file for the generator.
28
-     *
29
-     * @return string
30
-     */
31
-    protected function getStub()
32
-    {
33
-        return __DIR__.'/stubs/notification.stub';
34
-    }
35
-    /**
36
-     * Get the destination class path.
37
-     *
38
-     * @param string $name
39
-     *
40
-     * @return string
41
-     */
42
-    protected function getPath($name)
43
-    {
44
-        return module_path('notifications', 'Notifications/'.$name.'.php');
45
-    }
46
-    /**
47
-     * Parse the name and format according to the root namespace.
48
-     *
49
-     * @param string $name
50
-     *
51
-     * @return string
52
-     */
53
-    protected function qualifyClass($name)
54
-    {
55
-        return $name;
56
-    }
57
-    /**
58
-     * Replace namespace in notification stub.
59
-     *
60
-     * @param string $name
61
-     *
62
-     * @return string
63
-     */
64
-    protected function getNamespace($name)
65
-    {
66
-        return module_class('notifications', 'Notifications');
67
-    }
14
+	/**
15
+	 * The console command description.
16
+	 *
17
+	 * @var string
18
+	 */
19
+	protected $description = 'Create a new module notification class';
20
+	/**
21
+	 * String to store the command type.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $type = 'Module notification';
26
+	/**
27
+	 * Get the stub file for the generator.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	protected function getStub()
32
+	{
33
+		return __DIR__.'/stubs/notification.stub';
34
+	}
35
+	/**
36
+	 * Get the destination class path.
37
+	 *
38
+	 * @param string $name
39
+	 *
40
+	 * @return string
41
+	 */
42
+	protected function getPath($name)
43
+	{
44
+		return module_path('notifications', 'Notifications/'.$name.'.php');
45
+	}
46
+	/**
47
+	 * Parse the name and format according to the root namespace.
48
+	 *
49
+	 * @param string $name
50
+	 *
51
+	 * @return string
52
+	 */
53
+	protected function qualifyClass($name)
54
+	{
55
+		return $name;
56
+	}
57
+	/**
58
+	 * Replace namespace in notification stub.
59
+	 *
60
+	 * @param string $name
61
+	 *
62
+	 * @return string
63
+	 */
64
+	protected function getNamespace($name)
65
+	{
66
+		return module_class('notifications', 'Notifications');
67
+	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Database/Seeds/NotificationsTableSeeder.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@
 block discarded – undo
6 6
 
7 7
 class NotificationsTableSeeder 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 settings table.
18
-         */
19
-        \DB::table('permissions')->insert(
20
-        	[
21
-        		/**
22
-        		 * notifications model permissions.
23
-        		 */
24
-	        	[
25
-	        	'name'       => 'all',
26
-	        	'model'      => 'notifications',
27
-	        	'created_at' => \DB::raw('NOW()'),
28
-	        	'updated_at' => \DB::raw('NOW()')
29
-	        	],
30
-	        	[
31
-	        	'name'       => 'unread',
32
-	        	'model'      => 'notifications',
33
-	        	'created_at' => \DB::raw('NOW()'),
34
-	        	'updated_at' => \DB::raw('NOW()')
35
-	        	],
36
-	        	[
37
-	        	'name'       => 'markAsRead',
38
-	        	'model'      => 'notifications',
39
-	        	'created_at' => \DB::raw('NOW()'),
40
-	        	'updated_at' => \DB::raw('NOW()')
41
-	        	],
42
-	        	[
43
-	        	'name'       => 'markAllAsRead',
44
-	        	'model'      => 'notifications',
45
-	        	'created_at' => \DB::raw('NOW()'),
46
-	        	'updated_at' => \DB::raw('NOW()')
47
-	        	]
48
-        	]
49
-        );
50
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		/**
17
+		 * Insert the permissions related to settings table.
18
+		 */
19
+		\DB::table('permissions')->insert(
20
+			[
21
+				/**
22
+				 * notifications model permissions.
23
+				 */
24
+				[
25
+				'name'       => 'all',
26
+				'model'      => 'notifications',
27
+				'created_at' => \DB::raw('NOW()'),
28
+				'updated_at' => \DB::raw('NOW()')
29
+				],
30
+				[
31
+				'name'       => 'unread',
32
+				'model'      => 'notifications',
33
+				'created_at' => \DB::raw('NOW()'),
34
+				'updated_at' => \DB::raw('NOW()')
35
+				],
36
+				[
37
+				'name'       => 'markAsRead',
38
+				'model'      => 'notifications',
39
+				'created_at' => \DB::raw('NOW()'),
40
+				'updated_at' => \DB::raw('NOW()')
41
+				],
42
+				[
43
+				'name'       => 'markAllAsRead',
44
+				'model'      => 'notifications',
45
+				'created_at' => \DB::raw('NOW()'),
46
+				'updated_at' => \DB::raw('NOW()')
47
+				]
48
+			]
49
+		);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Database/Factories/NotificationFactory.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) {
4
-    return [
4
+	return [
5 5
 		'type'            => '',
6 6
 		'notifiable_type' => '',
7 7
 		'notifiable_id'   => '',
@@ -9,5 +9,5 @@  discard block
 block discarded – undo
9 9
 		'read_at'         => null,
10 10
 		'created_at'      => $faker->dateTimeBetween('-1 years', 'now'),
11 11
 		'updated_at'      => $faker->dateTimeBetween('-1 years', 'now')
12
-    ];
12
+	];
13 13
 });
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Notifications\Notification::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'type'            => '',
6 6
 		'notifiable_type' => '',
Please login to merge, or discard this patch.
V1/Notifications/Database/Migrations/2016_01_24_111941_notifications.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class Notifications extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('notifications', function (Blueprint $table) {
17
-            $table->uuid('id')->primary();
18
-            $table->string('type');
19
-            $table->morphs('notifiable');
20
-            $table->text('data');
21
-            $table->timestamp('read_at')->nullable();
22
-            $table->timestamps();
23
-        });
24
-    }
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('notifications', function (Blueprint $table) {
17
+			$table->uuid('id')->primary();
18
+			$table->string('type');
19
+			$table->morphs('notifiable');
20
+			$table->text('data');
21
+			$table->timestamp('read_at')->nullable();
22
+			$table->timestamps();
23
+		});
24
+	}
25 25
 
26
-    /**
27
-     * Reverse the migrations.
28
-     *
29
-     * @return void
30
-     */
31
-    public function down()
32
-    {
33
-        Schema::dropIfExists('notifications');
34
-    }
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		Schema::dropIfExists('notifications');
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('notifications', function (Blueprint $table) {
16
+        Schema::create('notifications', function(Blueprint $table) {
17 17
             $table->uuid('id')->primary();
18 18
             $table->string('type');
19 19
             $table->morphs('notifiable');
Please login to merge, or discard this patch.
Database/Migrations/2017_11_22_162811_create_failed_jobs_table.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class CreateFailedJobsTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('failed_jobs', function (Blueprint $table) {
17
-            $table->bigIncrements('id');
18
-            $table->text('connection');
19
-            $table->text('queue');
20
-            $table->longText('payload');
21
-            $table->longText('exception');
22
-            $table->timestamp('failed_at')->useCurrent();
23
-        });
24
-    }
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('failed_jobs', function (Blueprint $table) {
17
+			$table->bigIncrements('id');
18
+			$table->text('connection');
19
+			$table->text('queue');
20
+			$table->longText('payload');
21
+			$table->longText('exception');
22
+			$table->timestamp('failed_at')->useCurrent();
23
+		});
24
+	}
25 25
 
26
-    /**
27
-     * Reverse the migrations.
28
-     *
29
-     * @return void
30
-     */
31
-    public function down()
32
-    {
33
-        Schema::dropIfExists('failed_jobs');
34
-    }
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		Schema::dropIfExists('failed_jobs');
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('failed_jobs', function (Blueprint $table) {
16
+        Schema::create('failed_jobs', function(Blueprint $table) {
17 17
             $table->bigIncrements('id');
18 18
             $table->text('connection');
19 19
             $table->text('queue');
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/OauthClientsController.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,46 +8,46 @@
 block discarded – undo
8 8
 
9 9
 class OauthClientsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'oauthClients';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'oauthClients';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-        'name'                   => 'required|max:255',
25
-        'redirect'               => 'required|url',
26
-        'user_id'                => 'required|array|exists:users,id',
27
-        'personal_access_client' => 'boolean',
28
-        'password_client'        => 'boolean',
29
-        'revoked'                => 'boolean'
30
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+		'name'                   => 'required|max:255',
25
+		'redirect'               => 'required|url',
26
+		'user_id'                => 'required|array|exists:users,id',
27
+		'personal_access_client' => 'boolean',
28
+		'password_client'        => 'boolean',
29
+		'revoked'                => 'boolean'
30
+	];
31 31
 
32
-    /**
33
-     * Revoke the given client.
34
-     *
35
-     * @param  integer  $clientId
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function revoke($clientId)
39
-    {
40
-        return \Response::json($this->repo->revoke($clientId), 200);
41
-    }
32
+	/**
33
+	 * Revoke the given client.
34
+	 *
35
+	 * @param  integer  $clientId
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function revoke($clientId)
39
+	{
40
+		return \Response::json($this->repo->revoke($clientId), 200);
41
+	}
42 42
 
43
-    /**
44
-     * Regenerate seceret for the given client.
45
-     *
46
-     * @param  integer  $clientId
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function regenerateSecret($clientId)
50
-    {
51
-        return \Response::json($this->repo->regenerateSecret($clientId), 200);
52
-    }
43
+	/**
44
+	 * Regenerate seceret for the given client.
45
+	 *
46
+	 * @param  integer  $clientId
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function regenerateSecret($clientId)
50
+	{
51
+		return \Response::json($this->repo->regenerateSecret($clientId), 200);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
      * to preform actions like (add, edit ... etc).
14 14
      * @var string
15 15
      */
16
-    protected $model               = 'oauthClients';
16
+    protected $model = 'oauthClients';
17 17
 
18 18
     /**
19 19
      * The validations rules used by the base api controller
20 20
      * to check before add.
21 21
      * @var array
22 22
      */
23
-    protected $validationRules  = [
23
+    protected $validationRules = [
24 24
         'name'                   => 'required|max:255',
25 25
         'redirect'               => 'required|url',
26 26
         'user_id'                => 'required|array|exists:users,id',
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Proxy/LoginProxy.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -5,105 +5,105 @@
 block discarded – undo
5 5
 
6 6
 class LoginProxy
7 7
 {
8
-    private $apiConsumer;
9
-
10
-    private $auth;
11
-
12
-    private $db;
13
-
14
-    private $request;
15
-
16
-    private $userRepository;
17
-
18
-    public function __construct(Application $app, UserRepository $userRepository) 
19
-    {
20
-
21
-        $this->userRepository = $userRepository;
22
-        $this->apiConsumer    = $app->make('apiconsumer');
23
-        $this->auth           = $app->make('auth');
24
-        $this->db             = $app->make('db');
25
-        $this->request        = $app->make('request');
26
-    }
27
-
28
-    /**
29
-     * Attempt to create an access token using user credentials.
30
-     *
31
-     * @param  array   $credentials
32
-     * @param  boolean $adminLogin
33
-     * @return array
34
-     */
35
-    public function login($credentials, $adminLogin = false)
36
-    {
37
-        $this->userRepository->login($credentials, $adminLogin);
38
-
39
-        return $this->proxy('password', [
40
-            'username' => $credentials['email'],
41
-            'password' => $credentials['password']
42
-        ]);
43
-    }
44
-
45
-    /**
46
-     * Attempt to refresh the access token useing the given refresh token.
47
-     * 
48
-     * @param  string $refreshToken
49
-     * @return array
50
-     */
51
-    public function refreshtoken($refreshToken)
52
-    {
53
-        return $this->proxy('refresh_token', [
54
-            'refresh_token' => $refreshToken
55
-        ]);
56
-    }
57
-
58
-    /**
59
-     * Proxy a request to the OAuth server.
60
-     *
61
-     * @param string $grantType what type of grant type should be proxied
62
-     * @param array 
63
-     */
64
-    public function proxy($grantType, array $data = [])
65
-    {
66
-        $data = array_merge($data, [
67
-            'client_id'     => env('PASSWORD_CLIENT_ID'),
68
-            'client_secret' => env('PASSWORD_CLIENT_SECRET'),
69
-            'grant_type'    => $grantType
70
-        ]);
71
-
72
-        $response = $this->apiConsumer->post('/oauth/token', $data);
73
-
74
-        if ( ! $response->isSuccessful()) 
75
-        {
76
-            if ($grantType == 'refresh_token') 
77
-            {
78
-                \ErrorHandler::invalidRefreshToken();
79
-            }
80
-
81
-            \ErrorHandler::loginFailed();
82
-        }
83
-
84
-        $data = json_decode($response->getContent());
85
-
86
-        return [
87
-            'access_token'  => $data->access_token,
88
-            'refresh_token' => $data->refresh_token,
89
-            'expires_in'    => $data->expires_in
90
-        ];
91
-    }
92
-
93
-    /**
94
-     * Logs out the user. We revoke access token and refresh token.
95
-     */
96
-    public function logout()
97
-    {
98
-        $accessToken = $this->auth->user()->token();
99
-
100
-        $this->db
101
-            ->table('oauth_refresh_tokens')
102
-            ->where('access_token_id', $accessToken->id)
103
-            ->update([
104
-                'revoked' => true
105
-            ]);
106
-
107
-        $accessToken->revoke();
108
-    }
8
+	private $apiConsumer;
9
+
10
+	private $auth;
11
+
12
+	private $db;
13
+
14
+	private $request;
15
+
16
+	private $userRepository;
17
+
18
+	public function __construct(Application $app, UserRepository $userRepository) 
19
+	{
20
+
21
+		$this->userRepository = $userRepository;
22
+		$this->apiConsumer    = $app->make('apiconsumer');
23
+		$this->auth           = $app->make('auth');
24
+		$this->db             = $app->make('db');
25
+		$this->request        = $app->make('request');
26
+	}
27
+
28
+	/**
29
+	 * Attempt to create an access token using user credentials.
30
+	 *
31
+	 * @param  array   $credentials
32
+	 * @param  boolean $adminLogin
33
+	 * @return array
34
+	 */
35
+	public function login($credentials, $adminLogin = false)
36
+	{
37
+		$this->userRepository->login($credentials, $adminLogin);
38
+
39
+		return $this->proxy('password', [
40
+			'username' => $credentials['email'],
41
+			'password' => $credentials['password']
42
+		]);
43
+	}
44
+
45
+	/**
46
+	 * Attempt to refresh the access token useing the given refresh token.
47
+	 * 
48
+	 * @param  string $refreshToken
49
+	 * @return array
50
+	 */
51
+	public function refreshtoken($refreshToken)
52
+	{
53
+		return $this->proxy('refresh_token', [
54
+			'refresh_token' => $refreshToken
55
+		]);
56
+	}
57
+
58
+	/**
59
+	 * Proxy a request to the OAuth server.
60
+	 *
61
+	 * @param string $grantType what type of grant type should be proxied
62
+	 * @param array 
63
+	 */
64
+	public function proxy($grantType, array $data = [])
65
+	{
66
+		$data = array_merge($data, [
67
+			'client_id'     => env('PASSWORD_CLIENT_ID'),
68
+			'client_secret' => env('PASSWORD_CLIENT_SECRET'),
69
+			'grant_type'    => $grantType
70
+		]);
71
+
72
+		$response = $this->apiConsumer->post('/oauth/token', $data);
73
+
74
+		if ( ! $response->isSuccessful()) 
75
+		{
76
+			if ($grantType == 'refresh_token') 
77
+			{
78
+				\ErrorHandler::invalidRefreshToken();
79
+			}
80
+
81
+			\ErrorHandler::loginFailed();
82
+		}
83
+
84
+		$data = json_decode($response->getContent());
85
+
86
+		return [
87
+			'access_token'  => $data->access_token,
88
+			'refresh_token' => $data->refresh_token,
89
+			'expires_in'    => $data->expires_in
90
+		];
91
+	}
92
+
93
+	/**
94
+	 * Logs out the user. We revoke access token and refresh token.
95
+	 */
96
+	public function logout()
97
+	{
98
+		$accessToken = $this->auth->user()->token();
99
+
100
+		$this->db
101
+			->table('oauth_refresh_tokens')
102
+			->where('access_token_id', $accessToken->id)
103
+			->update([
104
+				'revoked' => true
105
+			]);
106
+
107
+		$accessToken->revoke();
108
+	}
109 109
 }
110 110
\ No newline at end of file
Please login to merge, or discard this patch.