Completed
Push — master ( b7f417...e961f1 )
by Sherif
02:36
created
V1/Notifications/Database/Factories/PushNotificationDeviceFactory.php 2 patches
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\PushNotificationDevice::class, function (Faker\Generator $faker) {
3
+$factory->define(App\Modules\V1\Notifications\PushNotificationDevice::class, function(Faker\Generator $faker) {
4 4
     return [
5 5
 		'device_token' => $faker->sha1(),
6 6
 		'user_id'      => $faker->randomDigitNotNull(),
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $factory->define(App\Modules\V1\Notifications\PushNotificationDevice::class, function (Faker\Generator $faker) {
4
-    return [
4
+	return [
5 5
 		'device_token' => $faker->sha1(),
6 6
 		'user_id'      => $faker->randomDigitNotNull(),
7 7
 		'created_at'   => $faker->dateTimeBetween('-1 years', 'now'),
8 8
 		'updated_at'   => $faker->dateTimeBetween('-1 years', 'now')
9
-    ];
9
+	];
10 10
 });
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
Database/Migrations/2016_01_24_111942_push_notifications_devices.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 			$table->unique(array('device_token', 'user_id'));
21 21
 			$table->softDeletes();
22 22
 			$table->timestamps();
23
-        });
23
+		});
24 24
 	}
25 25
 
26 26
 	/**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('push_notifications_devices', function (Blueprint $table) {
15
+		Schema::create('push_notifications_devices', function(Blueprint $table) {
16 16
 			$table->increments('id');
17 17
 			$table->string('device_token');
18 18
 			$table->integer('user_id');
Please login to merge, or discard this patch.
Notifications/Database/Migrations/2017_10_26_154804_create_jobs_table.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
 
7 7
 class CreateJobsTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('jobs', function (Blueprint $table) {
17
-            $table->bigIncrements('id');
18
-            $table->string('queue');
19
-            $table->longText('payload');
20
-            $table->tinyInteger('attempts')->unsigned();
21
-            $table->unsignedInteger('reserved_at')->nullable();
22
-            $table->unsignedInteger('available_at');
23
-            $table->unsignedInteger('created_at');
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('jobs', function (Blueprint $table) {
17
+			$table->bigIncrements('id');
18
+			$table->string('queue');
19
+			$table->longText('payload');
20
+			$table->tinyInteger('attempts')->unsigned();
21
+			$table->unsignedInteger('reserved_at')->nullable();
22
+			$table->unsignedInteger('available_at');
23
+			$table->unsignedInteger('created_at');
24 24
 
25
-            $table->index(['queue', 'reserved_at']);
26
-        });
27
-    }
25
+			$table->index(['queue', 'reserved_at']);
26
+		});
27
+	}
28 28
 
29
-    /**
30
-     * Reverse the migrations.
31
-     *
32
-     * @return void
33
-     */
34
-    public function down()
35
-    {
36
-        Schema::dropIfExists('jobs');
37
-    }
29
+	/**
30
+	 * Reverse the migrations.
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public function down()
35
+	{
36
+		Schema::dropIfExists('jobs');
37
+	}
38 38
 }
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('jobs', function (Blueprint $table) {
16
+        Schema::create('jobs', function(Blueprint $table) {
17 17
             $table->bigIncrements('id');
18 18
             $table->string('queue');
19 19
             $table->longText('payload');
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclUser.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use App\User;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5
-use Illuminate\Notifications\Notifiable;
6 5
 use Laravel\Passport\HasApiTokens;
7 6
 
8 7
 class AclUser extends User {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,8 +67,7 @@
 block discarded – undo
67 67
                 }
68 68
 
69 69
                 $tokens[] = $device->device_token;
70
-            } 
71
-            catch (\Exception $e) 
70
+            } catch (\Exception $e) 
72 71
             {
73 72
                 $device->forceDelete();
74 73
             }
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -7,119 +7,119 @@
 block discarded – undo
7 7
 
8 8
 class AclUser extends User {
9 9
 
10
-    use SoftDeletes, HasApiTokens;
11
-    protected $table    = 'users';
12
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
-    protected $hidden   = ['password', 'remember_token','deleted_at', 'two_factor_code'];
14
-    protected $guarded  = ['id'];
15
-    protected $fillable = ['name', 'email', 'password'];
16
-    public $searchable  = ['name', 'email'];
10
+	use SoftDeletes, HasApiTokens;
11
+	protected $table    = 'users';
12
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
+	protected $hidden   = ['password', 'remember_token','deleted_at', 'two_factor_code'];
14
+	protected $guarded  = ['id'];
15
+	protected $fillable = ['name', 'email', 'password'];
16
+	public $searchable  = ['name', 'email'];
17 17
     
18
-    public function getCreatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
-    }
22
-
23
-    public function getUpdatedAtAttribute($value)
24
-    {
25
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
-    }
27
-
28
-    public function getDeletedAtAttribute($value)
29
-    {
30
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
31
-    }
32
-
33
-    /**
34
-     * Encrypt the password attribute before
35
-     * saving it in the storage.
36
-     * 
37
-     * @param string $value 
38
-     */
39
-    public function setPasswordAttribute($value)
40
-    {
41
-        $this->attributes['password'] = bcrypt($value);
42
-    }
43
-
44
-    /**
45
-     * Get the entity's notifications.
46
-     */
47
-    public function notifications()
48
-    {
49
-        return $this->morphMany('\App\Modules\V1\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc');
50
-    }
51
-
52
-    /**
53
-     * Get the entity's read notifications.
54
-     */
55
-    public function readNotifications()
56
-    {
57
-        return $this->notifications()->whereNotNull('read_at');
58
-    }
59
-
60
-    /**
61
-     * Get the entity's unread notifications.
62
-     */
63
-    public function unreadNotifications()
64
-    {
65
-        return $this->notifications()->whereNull('read_at');
66
-    }
67
-
68
-    public function groups()
69
-    {
70
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
71
-    }
72
-
73
-    public function oauthClients()
74
-    {
75
-        return $this->hasMany('App\Modules\V1\Acl\OauthClient', 'user_id');
76
-    }
77
-
78
-    /**
79
-     * Return fcm device tokens that will be used in sending fcm notifications.
80
-     * 
81
-     * @return array
82
-     */
83
-    public function routeNotificationForFCM()
84
-    {
85
-        $devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
86
-        $tokens  = [];
87
-
88
-        foreach ($devices as $device) 
89
-        {
90
-            $accessToken = decrypt($device->access_token);
91
-
92
-            try
93
-            {
94
-                if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
95
-                {
96
-                    continue;
97
-                }
98
-
99
-                $tokens[] = $device->device_token;
100
-            } 
101
-            catch (\Exception $e) 
102
-            {
103
-                $device->forceDelete();
104
-            }
105
-        }
106
-
107
-        return $tokens;
108
-    }
109
-
110
-    /**
111
-     * The channels the user receives notification broadcasts on.
112
-     *
113
-     * @return string
114
-     */
115
-    public function receivesBroadcastNotificationsOn()
116
-    {
117
-        return 'users.' . $this->id;
118
-    }
18
+	public function getCreatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
+	}
22
+
23
+	public function getUpdatedAtAttribute($value)
24
+	{
25
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
+	}
27
+
28
+	public function getDeletedAtAttribute($value)
29
+	{
30
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
31
+	}
32
+
33
+	/**
34
+	 * Encrypt the password attribute before
35
+	 * saving it in the storage.
36
+	 * 
37
+	 * @param string $value 
38
+	 */
39
+	public function setPasswordAttribute($value)
40
+	{
41
+		$this->attributes['password'] = bcrypt($value);
42
+	}
43
+
44
+	/**
45
+	 * Get the entity's notifications.
46
+	 */
47
+	public function notifications()
48
+	{
49
+		return $this->morphMany('\App\Modules\V1\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc');
50
+	}
51
+
52
+	/**
53
+	 * Get the entity's read notifications.
54
+	 */
55
+	public function readNotifications()
56
+	{
57
+		return $this->notifications()->whereNotNull('read_at');
58
+	}
59
+
60
+	/**
61
+	 * Get the entity's unread notifications.
62
+	 */
63
+	public function unreadNotifications()
64
+	{
65
+		return $this->notifications()->whereNull('read_at');
66
+	}
67
+
68
+	public function groups()
69
+	{
70
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
71
+	}
72
+
73
+	public function oauthClients()
74
+	{
75
+		return $this->hasMany('App\Modules\V1\Acl\OauthClient', 'user_id');
76
+	}
77
+
78
+	/**
79
+	 * Return fcm device tokens that will be used in sending fcm notifications.
80
+	 * 
81
+	 * @return array
82
+	 */
83
+	public function routeNotificationForFCM()
84
+	{
85
+		$devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
86
+		$tokens  = [];
87
+
88
+		foreach ($devices as $device) 
89
+		{
90
+			$accessToken = decrypt($device->access_token);
91
+
92
+			try
93
+			{
94
+				if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
95
+				{
96
+					continue;
97
+				}
98
+
99
+				$tokens[] = $device->device_token;
100
+			} 
101
+			catch (\Exception $e) 
102
+			{
103
+				$device->forceDelete();
104
+			}
105
+		}
106
+
107
+		return $tokens;
108
+	}
109
+
110
+	/**
111
+	 * The channels the user receives notification broadcasts on.
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function receivesBroadcastNotificationsOn()
116
+	{
117
+		return 'users.' . $this->id;
118
+	}
119 119
     
120
-    public static function boot()
121
-    {
122
-        parent::boot();
123
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
124
-    }
120
+	public static function boot()
121
+	{
122
+		parent::boot();
123
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     use SoftDeletes, HasApiTokens;
11 11
     protected $table    = 'users';
12 12
     protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
-    protected $hidden   = ['password', 'remember_token','deleted_at', 'two_factor_code'];
13
+    protected $hidden   = ['password', 'remember_token', 'deleted_at', 'two_factor_code'];
14 14
     protected $guarded  = ['id'];
15 15
     protected $fillable = ['name', 'email', 'password'];
16 16
     public $searchable  = ['name', 'email'];
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function groups()
69 69
     {
70
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
70
+        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
71 71
     }
72 72
 
73 73
     public function oauthClients()
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function receivesBroadcastNotificationsOn()
116 116
     {
117
-        return 'users.' . $this->id;
117
+        return 'users.'.$this->id;
118 118
     }
119 119
     
120 120
     public static function boot()
Please login to merge, or discard this patch.
src/Modules/V1/Core/Console/Commands/GenerateDoc.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,6 +123,7 @@  discard block
 block discarded – undo
123 123
      * 
124 124
      * @param  array  &$route
125 125
      * @param  object $reflectionMethod]
126
+     * @param \ReflectionMethod $reflectionMethod
126 127
      * @return void
127 128
      */
128 129
     protected function processDocBlock(&$route, $reflectionMethod)
@@ -145,7 +146,7 @@  discard block
 block discarded – undo
145 146
      * Generate post body for the given route.
146 147
      * 
147 148
      * @param  array  &$route
148
-     * @param  object $reflectionMethod
149
+     * @param  \ReflectionMethod $reflectionMethod
149 150
      * @param  array  $validationRules
150 151
      * @return void
151 152
      */
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -6,272 +6,272 @@
 block discarded – undo
6 6
 
7 7
 class GenerateDoc extends Command
8 8
 {
9
-    /**
10
-     * The name and signature of the console command.
11
-     *
12
-     * @var string
13
-     */
14
-    protected $signature = 'doc:generate';
9
+	/**
10
+	 * The name and signature of the console command.
11
+	 *
12
+	 * @var string
13
+	 */
14
+	protected $signature = 'doc:generate';
15 15
 
16
-    /**
17
-     * The console command description.
18
-     *
19
-     * @var string
20
-     */
21
-    protected $description = 'Generate api documentation';
16
+	/**
17
+	 * The console command description.
18
+	 *
19
+	 * @var string
20
+	 */
21
+	protected $description = 'Generate api documentation';
22 22
 
23
-    /**
24
-     * Create a new command instance.
25
-     *
26
-     * @return void
27
-     */
28
-    public function __construct()
29
-    {
30
-        parent::__construct();
31
-    }
23
+	/**
24
+	 * Create a new command instance.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function __construct()
29
+	{
30
+		parent::__construct();
31
+	}
32 32
 
33
-    /**
34
-     * Execute the console command.
35
-     *
36
-     * @return mixed
37
-     */
38
-    public function handle()
39
-    {
40
-        $docData           = [];
41
-        $docData['models'] = [];
42
-        $routes            = $this->getRoutes();
43
-        foreach ($routes as $route) 
44
-        {
45
-            if ($route) 
46
-            {
47
-                $actoinArray       = explode('@', $route['action']);
48
-                $controller        = $actoinArray[0];
49
-                $method            = $actoinArray[1];
50
-                $route['name']     = $method !== 'index' ? $method : 'list';
33
+	/**
34
+	 * Execute the console command.
35
+	 *
36
+	 * @return mixed
37
+	 */
38
+	public function handle()
39
+	{
40
+		$docData           = [];
41
+		$docData['models'] = [];
42
+		$routes            = $this->getRoutes();
43
+		foreach ($routes as $route) 
44
+		{
45
+			if ($route) 
46
+			{
47
+				$actoinArray       = explode('@', $route['action']);
48
+				$controller        = $actoinArray[0];
49
+				$method            = $actoinArray[1];
50
+				$route['name']     = $method !== 'index' ? $method : 'list';
51 51
                 
52
-                $reflectionClass   = new \ReflectionClass($controller);
53
-                $reflectionMethod  = $reflectionClass->getMethod($method);
54
-                $classProperties   = $reflectionClass->getDefaultProperties();
55
-                $skipLoginCheck    = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false;
56
-                $validationRules   = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false;
52
+				$reflectionClass   = new \ReflectionClass($controller);
53
+				$reflectionMethod  = $reflectionClass->getMethod($method);
54
+				$classProperties   = $reflectionClass->getDefaultProperties();
55
+				$skipLoginCheck    = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false;
56
+				$validationRules   = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false;
57 57
 
58
-                $this->processDocBlock($route, $reflectionMethod);
59
-                $this->getHeaders($route, $method, $skipLoginCheck);
60
-                $this->getPostData($route, $reflectionMethod, $validationRules);
58
+				$this->processDocBlock($route, $reflectionMethod);
59
+				$this->getHeaders($route, $method, $skipLoginCheck);
60
+				$this->getPostData($route, $reflectionMethod, $validationRules);
61 61
 
62
-                $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']);
62
+				$route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']);
63 63
 
64
-                preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module);
65
-                $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/' . $module[1] . '/') - 1)][] = $route;
64
+				preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module);
65
+				$docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/' . $module[1] . '/') - 1)][] = $route;
66 66
 
67
-                $this->getModels($classProperties['model'], $docData);
68
-            }
69
-        }
67
+				$this->getModels($classProperties['model'], $docData);
68
+			}
69
+		}
70 70
         
71
-        $docData['errors'] = $this->getErrors();
72
-        \File::put(app_path('Modules/V1/Core/Resources/api.json'), json_encode($docData));
73
-    }
71
+		$docData['errors'] = $this->getErrors();
72
+		\File::put(app_path('Modules/V1/Core/Resources/api.json'), json_encode($docData));
73
+	}
74 74
 
75
-    /**
76
-     * Get list of all registered routes.
77
-     * 
78
-     * @return collection
79
-     */
80
-    protected function getRoutes()
81
-    {
82
-        return collect(\Route::getRoutes())->map(function ($route) {
83
-            if (strpos($route->uri(), 'api/v') !== false) 
84
-            {
85
-                return [
86
-                    'method' => $route->methods()[0],
87
-                    'uri'    => $route->uri(),
88
-                    'action' => $route->getActionName(),
89
-                    'prefix' => $route->getPrefix()
90
-                ];
91
-            }
92
-            return false;
93
-        })->all();
94
-    }
75
+	/**
76
+	 * Get list of all registered routes.
77
+	 * 
78
+	 * @return collection
79
+	 */
80
+	protected function getRoutes()
81
+	{
82
+		return collect(\Route::getRoutes())->map(function ($route) {
83
+			if (strpos($route->uri(), 'api/v') !== false) 
84
+			{
85
+				return [
86
+					'method' => $route->methods()[0],
87
+					'uri'    => $route->uri(),
88
+					'action' => $route->getActionName(),
89
+					'prefix' => $route->getPrefix()
90
+				];
91
+			}
92
+			return false;
93
+		})->all();
94
+	}
95 95
 
96
-    /**
97
-     * Generate headers for the given route.
98
-     * 
99
-     * @param  array  &$route
100
-     * @param  string $method
101
-     * @param  array  $skipLoginCheck
102
-     * @return void
103
-     */
104
-    protected function getHeaders(&$route, $method, $skipLoginCheck)
105
-    {
106
-        $route['headers'] = [
107
-        'Accept'         => 'application/json',
108
-        'Content-Type'   => 'application/json',
109
-        'locale'         => 'The language of the returned data: ar, en or all.',
110
-        'time-zone-diff' => 'Timezone difference between UTC and Local Time',
111
-        ];
96
+	/**
97
+	 * Generate headers for the given route.
98
+	 * 
99
+	 * @param  array  &$route
100
+	 * @param  string $method
101
+	 * @param  array  $skipLoginCheck
102
+	 * @return void
103
+	 */
104
+	protected function getHeaders(&$route, $method, $skipLoginCheck)
105
+	{
106
+		$route['headers'] = [
107
+		'Accept'         => 'application/json',
108
+		'Content-Type'   => 'application/json',
109
+		'locale'         => 'The language of the returned data: ar, en or all.',
110
+		'time-zone-diff' => 'Timezone difference between UTC and Local Time',
111
+		];
112 112
 
113 113
 
114
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
115
-        {
116
-            $route['headers']['Authrization'] = 'Bearer {token}';
117
-        }
118
-    }
114
+		if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
115
+		{
116
+			$route['headers']['Authrization'] = 'Bearer {token}';
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * Generate description and params for the given route
122
-     * based on the docblock.
123
-     * 
124
-     * @param  array  &$route
125
-     * @param  object $reflectionMethod]
126
-     * @return void
127
-     */
128
-    protected function processDocBlock(&$route, $reflectionMethod)
129
-    {
130
-        $factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
131
-        $docblock                = $factory->create($reflectionMethod->getDocComment());
132
-        $route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
133
-        $params                  = $docblock->getTagsByName('param');
134
-        $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
135
-        foreach ($params as $param) 
136
-        {
137
-            $name = $param->getVariableName();
138
-            if ($name !== 'request') 
139
-            {
140
-                $route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
141
-            }
142
-        }
143
-    }
120
+	/**
121
+	 * Generate description and params for the given route
122
+	 * based on the docblock.
123
+	 * 
124
+	 * @param  array  &$route
125
+	 * @param  object $reflectionMethod]
126
+	 * @return void
127
+	 */
128
+	protected function processDocBlock(&$route, $reflectionMethod)
129
+	{
130
+		$factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
131
+		$docblock                = $factory->create($reflectionMethod->getDocComment());
132
+		$route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
133
+		$params                  = $docblock->getTagsByName('param');
134
+		$route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
135
+		foreach ($params as $param) 
136
+		{
137
+			$name = $param->getVariableName();
138
+			if ($name !== 'request') 
139
+			{
140
+				$route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
141
+			}
142
+		}
143
+	}
144 144
 
145
-    /**
146
-     * Generate post body for the given route.
147
-     * 
148
-     * @param  array  &$route
149
-     * @param  object $reflectionMethod
150
-     * @param  array  $validationRules
151
-     * @return void
152
-     */
153
-    protected function getPostData(&$route, $reflectionMethod, $validationRules)
154
-    {
155
-        if ($route['method'] == 'POST') 
156
-        {
157
-            $body = $this->getMethodBody($reflectionMethod);
145
+	/**
146
+	 * Generate post body for the given route.
147
+	 * 
148
+	 * @param  array  &$route
149
+	 * @param  object $reflectionMethod
150
+	 * @param  array  $validationRules
151
+	 * @return void
152
+	 */
153
+	protected function getPostData(&$route, $reflectionMethod, $validationRules)
154
+	{
155
+		if ($route['method'] == 'POST') 
156
+		{
157
+			$body = $this->getMethodBody($reflectionMethod);
158 158
 
159
-            preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
160
-            if (count($match)) 
161
-            {
162
-                if ($match[1] == '$this->validationRules')
163
-                {
164
-                    $route['body'] = $validationRules;
165
-                }
166
-                else
167
-                {
168
-                    $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';');
169
-                }
159
+			preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
160
+			if (count($match)) 
161
+			{
162
+				if ($match[1] == '$this->validationRules')
163
+				{
164
+					$route['body'] = $validationRules;
165
+				}
166
+				else
167
+				{
168
+					$route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';');
169
+				}
170 170
 
171
-                foreach ($route['body'] as &$rule) 
172
-                {
173
-                    if(strpos($rule, 'unique'))
174
-                    {
175
-                        $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176
-                    }
177
-                    elseif(strpos($rule, 'exists'))
178
-                    {
179
-                        $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180
-                    }
181
-                }
182
-            }
183
-            else
184
-            {
185
-                $route['body'] = 'conditions';
186
-            }
187
-        }
188
-    }
171
+				foreach ($route['body'] as &$rule) 
172
+				{
173
+					if(strpos($rule, 'unique'))
174
+					{
175
+						$rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176
+					}
177
+					elseif(strpos($rule, 'exists'))
178
+					{
179
+						$rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180
+					}
181
+				}
182
+			}
183
+			else
184
+			{
185
+				$route['body'] = 'conditions';
186
+			}
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * Generate application errors.
192
-     * 
193
-     * @return array
194
-     */
195
-    protected function getErrors()
196
-    {
197
-        $errors          = [];
198
-        $reflectionClass = new \ReflectionClass('App\Modules\V1\Core\Utl\ErrorHandler');
199
-        foreach ($reflectionClass->getMethods() as $method) 
200
-        {
201
-            $methodName       = $method->getName();
202
-            $reflectionMethod = $reflectionClass->getMethod($methodName);
203
-            $body             = $this->getMethodBody($reflectionMethod);
190
+	/**
191
+	 * Generate application errors.
192
+	 * 
193
+	 * @return array
194
+	 */
195
+	protected function getErrors()
196
+	{
197
+		$errors          = [];
198
+		$reflectionClass = new \ReflectionClass('App\Modules\V1\Core\Utl\ErrorHandler');
199
+		foreach ($reflectionClass->getMethods() as $method) 
200
+		{
201
+			$methodName       = $method->getName();
202
+			$reflectionMethod = $reflectionClass->getMethod($methodName);
203
+			$body             = $this->getMethodBody($reflectionMethod);
204 204
 
205
-            preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
205
+			preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
206 206
 
207
-            if (count($match)) 
208
-            {
209
-                $errors[$match[1]][] = $methodName;
210
-            }
211
-        }
207
+			if (count($match)) 
208
+			{
209
+				$errors[$match[1]][] = $methodName;
210
+			}
211
+		}
212 212
 
213
-        return $errors;
214
-    }
213
+		return $errors;
214
+	}
215 215
 
216
-    /**
217
-     * Get the given method body code.
218
-     * 
219
-     * @param  object $reflectionMethod
220
-     * @return string
221
-     */
222
-    protected function getMethodBody($reflectionMethod)
223
-    {
224
-        $filename   = $reflectionMethod->getFileName();
225
-        $start_line = $reflectionMethod->getStartLine() - 1;
226
-        $end_line   = $reflectionMethod->getEndLine();
227
-        $length     = $end_line - $start_line;         
228
-        $source     = file($filename);
229
-        $body       = implode("", array_slice($source, $start_line, $length));
230
-        $body       = trim(preg_replace('/\s+/', '', $body));
216
+	/**
217
+	 * Get the given method body code.
218
+	 * 
219
+	 * @param  object $reflectionMethod
220
+	 * @return string
221
+	 */
222
+	protected function getMethodBody($reflectionMethod)
223
+	{
224
+		$filename   = $reflectionMethod->getFileName();
225
+		$start_line = $reflectionMethod->getStartLine() - 1;
226
+		$end_line   = $reflectionMethod->getEndLine();
227
+		$length     = $end_line - $start_line;         
228
+		$source     = file($filename);
229
+		$body       = implode("", array_slice($source, $start_line, $length));
230
+		$body       = trim(preg_replace('/\s+/', '', $body));
231 231
 
232
-        return $body;
233
-    }
232
+		return $body;
233
+	}
234 234
 
235
-    /**
236
-     * Get example object of all availble models.
237
-     * 
238
-     * @param  string $modelName
239
-     * @param  array  $docData
240
-     * @return string
241
-     */
242
-    protected function getModels($modelName, &$docData)
243
-    {
244
-        if ($modelName && ! array_key_exists($modelName, $docData['models'])) 
245
-        {
246
-            $modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass;
247
-            $model      = factory($modelClass)->make();
248
-            $modelArr   = $model->toArray();
235
+	/**
236
+	 * Get example object of all availble models.
237
+	 * 
238
+	 * @param  string $modelName
239
+	 * @param  array  $docData
240
+	 * @return string
241
+	 */
242
+	protected function getModels($modelName, &$docData)
243
+	{
244
+		if ($modelName && ! array_key_exists($modelName, $docData['models'])) 
245
+		{
246
+			$modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass;
247
+			$model      = factory($modelClass)->make();
248
+			$modelArr   = $model->toArray();
249 249
 
250
-            if ( $model->trans && ! $model->trans->count()) 
251
-            {
252
-                $modelArr['trans'] = [
253
-                    'en' => factory($modelClass . 'Translation')->make()->toArray()
254
-                ];
255
-            }
250
+			if ( $model->trans && ! $model->trans->count()) 
251
+			{
252
+				$modelArr['trans'] = [
253
+					'en' => factory($modelClass . 'Translation')->make()->toArray()
254
+				];
255
+			}
256 256
 
257
-            $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
258
-        }
259
-    }
257
+			$docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
258
+		}
259
+	}
260 260
 
261
-    /**
262
-     * Get the route response object type.
263
-     * 
264
-     * @param  string $modelName
265
-     * @param  string $method
266
-     * @param  string $returnDocBlock
267
-     * @return array
268
-     */
269
-    protected function getResponseObject($modelName, $method, $returnDocBlock)
270
-    {
271
-        $config    = \CoreConfig::getConfig();
272
-        $relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false;
273
-        $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
261
+	/**
262
+	 * Get the route response object type.
263
+	 * 
264
+	 * @param  string $modelName
265
+	 * @param  string $method
266
+	 * @param  string $returnDocBlock
267
+	 * @return array
268
+	 */
269
+	protected function getResponseObject($modelName, $method, $returnDocBlock)
270
+	{
271
+		$config    = \CoreConfig::getConfig();
272
+		$relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false;
273
+		$modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
274 274
 
275
-        return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
276
-    }
275
+		return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
276
+	}
277 277
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']);
63 63
 
64 64
                 preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module);
65
-                $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/' . $module[1] . '/') - 1)][] = $route;
65
+                $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/'.$module[1].'/') - 1)][] = $route;
66 66
 
67 67
                 $this->getModels($classProperties['model'], $docData);
68 68
             }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     protected function getRoutes()
81 81
     {
82
-        return collect(\Route::getRoutes())->map(function ($route) {
82
+        return collect(\Route::getRoutes())->map(function($route) {
83 83
             if (strpos($route->uri(), 'api/v') !== false) 
84 84
             {
85 85
                 return [
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         ];
112 112
 
113 113
 
114
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
114
+        if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) 
115 115
         {
116 116
             $route['headers']['Authrization'] = 'Bearer {token}';
117 117
         }
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
                 }
166 166
                 else
167 167
                 {
168
-                    $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';');
168
+                    $route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';');
169 169
                 }
170 170
 
171 171
                 foreach ($route['body'] as &$rule) 
172 172
                 {
173
-                    if(strpos($rule, 'unique'))
173
+                    if (strpos($rule, 'unique'))
174 174
                     {
175 175
                         $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176 176
                     }
177
-                    elseif(strpos($rule, 'exists'))
177
+                    elseif (strpos($rule, 'exists'))
178 178
                     {
179 179
                         $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180 180
                     }
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
             $model      = factory($modelClass)->make();
248 248
             $modelArr   = $model->toArray();
249 249
 
250
-            if ( $model->trans && ! $model->trans->count()) 
250
+            if ($model->trans && ! $model->trans->count()) 
251 251
             {
252 252
                 $modelArr['trans'] = [
253
-                    'en' => factory($modelClass . 'Translation')->make()->toArray()
253
+                    'en' => factory($modelClass.'Translation')->make()->toArray()
254 254
                 ];
255 255
             }
256 256
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -162,8 +162,7 @@  discard block
 block discarded – undo
162 162
                 if ($match[1] == '$this->validationRules')
163 163
                 {
164 164
                     $route['body'] = $validationRules;
165
-                }
166
-                else
165
+                } else
167 166
                 {
168 167
                     $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';');
169 168
                 }
@@ -173,14 +172,12 @@  discard block
 block discarded – undo
173 172
                     if(strpos($rule, 'unique'))
174 173
                     {
175 174
                         $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
176
-                    }
177
-                    elseif(strpos($rule, 'exists'))
175
+                    } elseif(strpos($rule, 'exists'))
178 176
                     {
179 177
                         $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
180 178
                     }
181 179
                 }
182
-            }
183
-            else
180
+            } else
184 181
             {
185 182
                 $route['body'] = 'conditions';
186 183
             }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/ApiDocumentController.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 namespace App\Modules\V1\Core\Http\Controllers;
3 3
 
4 4
 use App\Http\Controllers\Controller;
5
-use Illuminate\Http\Request;
6 5
 
7 6
 class ApiDocumentController extends Controller
8 7
 {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
 			],
21 21
 			[
22 22
 				'title'   => 'email equal [email protected] and user is blocked:',
23
-				'content' => ['and' => ['email' => '[email protected]','blocked' => 1]]
23
+				'content' => ['and' => ['email' => '[email protected]', 'blocked' => 1]]
24 24
 			],
25 25
 			[
26 26
 				'title'   => 'email equal [email protected] or user is blocked:',
27
-				'content' => ['or' => ['email' => '[email protected]','blocked' => 1]]
27
+				'content' => ['or' => ['email' => '[email protected]', 'blocked' => 1]]
28 28
 			],
29 29
 			[
30 30
 				'title'   => 'email contain John:',
31
-				'content' => ['email' => ['op' => 'like','val' => '%John%']]
31
+				'content' => ['email' => ['op' => 'like', 'val' => '%John%']]
32 32
 			],
33 33
 			[
34 34
 				'title'   => 'user created after 2016-10-25:',
35
-				'content' => ['created_at' => ['op' => '>','val' => '2016-10-25']]
35
+				'content' => ['created_at' => ['op' => '>', 'val' => '2016-10-25']]
36 36
 			],
37 37
 			[
38 38
 				'title'   => 'user created between 2016-10-20 and 2016-10-25:',
39
-				'content' => ['created_at' => ['op' => 'between','val1' => '2016-10-20','val2' => '2016-10-25']]
39
+				'content' => ['created_at' => ['op' => 'between', 'val1' => '2016-10-20', 'val2' => '2016-10-25']]
40 40
 			],
41 41
 			[
42 42
 				'title'   => 'user id in 1,2,3:',
43
-				'content' => ['id' => ['op' => 'in','val' => [1, 2, 3]]]
43
+				'content' => ['id' => ['op' => 'in', 'val' => [1, 2, 3]]]
44 44
 			],
45 45
 			[
46 46
 				'title'   => 'user name is null:',
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			],
53 53
 			[
54 54
 				'title'   => 'user has group admin:',
55
-				'content' => ['groups' => ['op' => 'has','val' => ['name' => 'Admin']]]
55
+				'content' => ['groups' => ['op' => 'has', 'val' => ['name' => 'Admin']]]
56 56
 			]
57 57
 		];
58 58
 
Please login to merge, or discard this patch.
src/lang/en/errors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * List of error messages used in core module.
7
-     */
8
-    'unAuthorized'           => 'Please login before any action',
9
-    'invalidRefreshToken'    => 'Invalid refresh token',
10
-    'noPermissions'          => 'No permissions',
11
-    'loginFailed'            => 'Wrong mail or password',
12
-    'noSocialEmail'          => 'Couldn\'t retrieve email',
13
-    'userAlreadyRegistered'  => 'User already registered. Please login using email and password',
14
-    'connectionError'        => 'Connection error',
15
-    'redisNotRunning'        => 'Your redis notification server is\'t running',
16
-    'dbQueryError'           => 'Please check the given inputes',
17
-    'cannotCreateSetting'    => 'Can\'t create setting',
18
-    'cannotUpdateSettingKey' => 'Can\'t update setting key',
19
-    'userIsBlocked'          => 'You have been blocked',
20
-    'invalidResetToken'      => 'Reset password token is invalid',
21
-    'invalidResetPassword'   => 'Reset password is invalid',
22
-    'invalidOldPassword'     => 'Old password is invalid',
23
-    'notFound'               => 'The requested :replace not found',
24
-    'generalError'           => 'Something went wrong',
5
+	/**
6
+	 * List of error messages used in core module.
7
+	 */
8
+	'unAuthorized'           => 'Please login before any action',
9
+	'invalidRefreshToken'    => 'Invalid refresh token',
10
+	'noPermissions'          => 'No permissions',
11
+	'loginFailed'            => 'Wrong mail or password',
12
+	'noSocialEmail'          => 'Couldn\'t retrieve email',
13
+	'userAlreadyRegistered'  => 'User already registered. Please login using email and password',
14
+	'connectionError'        => 'Connection error',
15
+	'redisNotRunning'        => 'Your redis notification server is\'t running',
16
+	'dbQueryError'           => 'Please check the given inputes',
17
+	'cannotCreateSetting'    => 'Can\'t create setting',
18
+	'cannotUpdateSettingKey' => 'Can\'t update setting key',
19
+	'userIsBlocked'          => 'You have been blocked',
20
+	'invalidResetToken'      => 'Reset password token is invalid',
21
+	'invalidResetPassword'   => 'Reset password is invalid',
22
+	'invalidOldPassword'     => 'Old password is invalid',
23
+	'notFound'               => 'The requested :replace not found',
24
+	'generalError'           => 'Something went wrong',
25 25
 
26 26
 ];
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/lang/ar/errors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * List of error messages used in core module.
7
-     */
8
-    'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
-    'invalidRefreshToken'    => 'رمز التحديث غير صالح',
10
-    'noPermissions'          => 'لا توجد صلاحية',
11
-    'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
-    'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
-    'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
-    'connectionError'        => 'خطأ في الاتصال',
15
-    'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
-    'dbQueryError'           => 'خطا في البيانات',
17
-    'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
-    'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
-    'userIsBlocked'          => 'لقد تم حظرك',
20
-    'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
-    'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
-    'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
-    'notFound'               => 'ال :replace المطلوب غير موجود',
24
-    'generalError'           => 'حدث خطا ما',
5
+	/**
6
+	 * List of error messages used in core module.
7
+	 */
8
+	'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
+	'invalidRefreshToken'    => 'رمز التحديث غير صالح',
10
+	'noPermissions'          => 'لا توجد صلاحية',
11
+	'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
+	'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
+	'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
+	'connectionError'        => 'خطأ في الاتصال',
15
+	'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
+	'dbQueryError'           => 'خطا في البيانات',
17
+	'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
+	'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
+	'userIsBlocked'          => 'لقد تم حظرك',
20
+	'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
+	'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
+	'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
+	'notFound'               => 'ال :replace المطلوب غير موجود',
24
+	'generalError'           => 'حدث خطا ما',
25 25
 
26 26
 ];
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 4 patches
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -122,16 +122,13 @@  discard block
 block discarded – undo
122 122
         if ( ! $user = $this->first(['email' => $credentials['email']])) 
123 123
         {
124 124
             \ErrorHandler::loginFailed();
125
-        }
126
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
125
+        } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
127 126
         {
128 127
             \ErrorHandler::loginFailed();
129
-        }
130
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
128
+        } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
131 129
         {
132 130
             \ErrorHandler::loginFailed();
133
-        }
134
-        else if ($user->blocked)
131
+        } else if ($user->blocked)
135 132
         {
136 133
             \ErrorHandler::userIsBlocked();
137 134
         }
@@ -159,8 +156,7 @@  discard block
 block discarded – undo
159 156
         {
160 157
             $data = ['email' => $user->email, 'password' => ''];
161 158
             return $this->register($data);
162
-        }
163
-        else
159
+        } else
164 160
         {
165 161
             if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
166 162
             {
@@ -198,12 +194,10 @@  discard block
 block discarded – undo
198 194
         if ( ! $this->hasGroup('Admin'))
199 195
         {
200 196
             \ErrorHandler::noPermissions();
201
-        }
202
-        else if (\Auth::id() == $user_id)
197
+        } else if (\Auth::id() == $user_id)
203 198
         {
204 199
             \ErrorHandler::noPermissions();
205
-        }
206
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
200
+        } else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
207 201
         {
208 202
             \ErrorHandler::noPermissions();
209 203
         }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $user        = \Core::users()->find(\Auth::id(), $relations);
50 50
         foreach ($user->groups()->get() as $group)
51 51
         {
52
-            $group->permissions->each(function ($permission) use (&$permissions){
52
+            $group->permissions->each(function($permission) use (&$permissions){
53 53
                 $permissions[$permission->model][$permission->id] = $permission->name;
54 54
             });
55 55
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $user        = $user ?: $this->find(\Auth::id(), ['groups.permissions']);
73 73
         $permissions = [];
74 74
 
75
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
75
+        $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model){
76 76
             $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
77 77
         });
78 78
         
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function assignGroups($user_id, $group_ids)
104 104
     {
105
-        \DB::transaction(function () use ($user_id, $group_ids) {
105
+        \DB::transaction(function() use ($user_id, $group_ids) {
106 106
             $user = $this->find($user_id);
107 107
             $user->groups()->detach();
108 108
             $user->groups()->attach($group_ids);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $url   = $this->config['resetLink'];
252 252
         $token = \Password::getRepository()->create($user);
253 253
         
254
-        \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
254
+        \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function($m) use ($user) {
255 255
             $m->to($user->email, $user->name)->subject('Your Password Reset Link');
256 256
         });
257 257
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function resetPassword($credentials)
266 266
     {
267
-        $response = \Password::reset($credentials, function ($user, $password) {
267
+        $response = \Password::reset($credentials, function($user, $password) {
268 268
             $user->password = $password;
269 269
             $user->save();
270 270
         });
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * Reset the given user's password.
240 240
      *
241 241
      * @param  array  $credentials
242
-     * @return array
242
+     * @return string|null
243 243
      */
244 244
     public function resetPassword($credentials)
245 245
     {
@@ -322,7 +322,6 @@  discard block
 block discarded – undo
322 322
     /**
323 323
      * Save the given data to the logged in user.
324 324
      *
325
-     * @param  array $credentials
326 325
      * @return void
327 326
      */
328 327
     public function saveProfile($data) 
Please login to merge, or discard this patch.
Indentation   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -5,350 +5,350 @@
 block discarded – undo
5 5
 
6 6
 class UserRepository extends AbstractRepository
7 7
 {
8
-    /**
9
-     * Return the model full namespace.
10
-     * 
11
-     * @return string
12
-     */
13
-    protected function getModel()
14
-    {
15
-        return 'App\Modules\V1\Acl\AclUser';
16
-    }
17
-
18
-
19
-    /**
20
-     * Return the logged in user account.
21
-     *
22
-     * @param  array   $relations
23
-     * @return boolean
24
-     */
25
-    public function account($relations = [])
26
-    {
27
-        $permissions = [];
28
-        $user        = \Core::users()->find(\Auth::id(), $relations);
29
-        foreach ($user->groups()->get() as $group)
30
-        {
31
-            $group->permissions->each(function ($permission) use (&$permissions){
32
-                $permissions[$permission->model][$permission->id] = $permission->name;
33
-            });
34
-        }
35
-        $user->permissions = $permissions;
36
-
37
-       return $user;
38
-    }
39
-
40
-    /**
41
-     * Check if the logged in user or the given user 
42
-     * has the given permissions on the given model.
43
-     * 
44
-     * @param  string  $nameOfPermission
45
-     * @param  string  $model            
46
-     * @param  boolean $user
47
-     * @return boolean
48
-     */
49
-    public function can($nameOfPermission, $model, $user = false)
50
-    {      
51
-        $user        = $user ?: $this->find(\Auth::id(), ['groups.permissions']);
52
-        $permissions = [];
53
-
54
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
55
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
56
-        });
8
+	/**
9
+	 * Return the model full namespace.
10
+	 * 
11
+	 * @return string
12
+	 */
13
+	protected function getModel()
14
+	{
15
+		return 'App\Modules\V1\Acl\AclUser';
16
+	}
17
+
18
+
19
+	/**
20
+	 * Return the logged in user account.
21
+	 *
22
+	 * @param  array   $relations
23
+	 * @return boolean
24
+	 */
25
+	public function account($relations = [])
26
+	{
27
+		$permissions = [];
28
+		$user        = \Core::users()->find(\Auth::id(), $relations);
29
+		foreach ($user->groups()->get() as $group)
30
+		{
31
+			$group->permissions->each(function ($permission) use (&$permissions){
32
+				$permissions[$permission->model][$permission->id] = $permission->name;
33
+			});
34
+		}
35
+		$user->permissions = $permissions;
36
+
37
+	   return $user;
38
+	}
39
+
40
+	/**
41
+	 * Check if the logged in user or the given user 
42
+	 * has the given permissions on the given model.
43
+	 * 
44
+	 * @param  string  $nameOfPermission
45
+	 * @param  string  $model            
46
+	 * @param  boolean $user
47
+	 * @return boolean
48
+	 */
49
+	public function can($nameOfPermission, $model, $user = false)
50
+	{      
51
+		$user        = $user ?: $this->find(\Auth::id(), ['groups.permissions']);
52
+		$permissions = [];
53
+
54
+		$user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
55
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
56
+		});
57 57
         
58
-        return in_array($nameOfPermission, $permissions);
59
-    }
60
-
61
-    /**
62
-     * Check if the logged in user has the given group.
63
-     * 
64
-     * @param  string  $groupName
65
-     * @param  integer $userId
66
-     * @return boolean
67
-     */
68
-    public function hasGroup($groupName, $userId = false)
69
-    {
70
-        $userId = $userId ?: \Auth::id();
71
-        $groups = $this->find($userId)->groups;
72
-        return $groups->pluck('name')->search($groupName, true) === false ? false : true;
73
-    }
74
-
75
-    /**
76
-     * Assign the given group ids to the given user.
77
-     * 
78
-     * @param  integer $user_id    
79
-     * @param  array   $group_ids
80
-     * @return object
81
-     */
82
-    public function assignGroups($user_id, $group_ids)
83
-    {
84
-        \DB::transaction(function () use ($user_id, $group_ids) {
85
-            $user = $this->find($user_id);
86
-            $user->groups()->detach();
87
-            $user->groups()->attach($group_ids);
88
-        });
89
-
90
-        return $this->find($user_id);
91
-    }
92
-
93
-    /**
94
-     * Handle a login request to the application.
95
-     * 
96
-     * @param  array   $credentials    
97
-     * @param  boolean $adminLogin
98
-     * @return object
99
-     */
100
-    public function login($credentials, $adminLogin = false)
101
-    {
102
-        if ( ! $user = $this->first(['email' => $credentials['email']])) 
103
-        {
104
-            \ErrorHandler::loginFailed();
105
-        }
106
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
107
-        {
108
-            \ErrorHandler::loginFailed();
109
-        }
110
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
111
-        {
112
-            \ErrorHandler::loginFailed();
113
-        }
114
-        else if ($user->blocked)
115
-        {
116
-            \ErrorHandler::userIsBlocked();
117
-        }
118
-
119
-        return $user;
120
-    }
121
-
122
-    /**
123
-     * Handle a social login request of the none admin to the application.
124
-     * 
125
-     * @param  array   $credentials
126
-     * @return array
127
-     */
128
-    public function loginSocial($credentials)
129
-    {
130
-        $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
131
-        $user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
132
-
133
-        if ( ! $user->email)
134
-        {
135
-            \ErrorHandler::noSocialEmail();
136
-        }
137
-
138
-        if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
139
-        {
140
-            $data = ['email' => $user->email, 'password' => ''];
141
-            return $this->register($data);
142
-        }
143
-        else
144
-        {
145
-            if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
146
-            {
147
-                \ErrorHandler::userAlreadyRegistered();
148
-            }
149
-
150
-            $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy');
151
-            return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
152
-        }
153
-    }
58
+		return in_array($nameOfPermission, $permissions);
59
+	}
60
+
61
+	/**
62
+	 * Check if the logged in user has the given group.
63
+	 * 
64
+	 * @param  string  $groupName
65
+	 * @param  integer $userId
66
+	 * @return boolean
67
+	 */
68
+	public function hasGroup($groupName, $userId = false)
69
+	{
70
+		$userId = $userId ?: \Auth::id();
71
+		$groups = $this->find($userId)->groups;
72
+		return $groups->pluck('name')->search($groupName, true) === false ? false : true;
73
+	}
74
+
75
+	/**
76
+	 * Assign the given group ids to the given user.
77
+	 * 
78
+	 * @param  integer $user_id    
79
+	 * @param  array   $group_ids
80
+	 * @return object
81
+	 */
82
+	public function assignGroups($user_id, $group_ids)
83
+	{
84
+		\DB::transaction(function () use ($user_id, $group_ids) {
85
+			$user = $this->find($user_id);
86
+			$user->groups()->detach();
87
+			$user->groups()->attach($group_ids);
88
+		});
89
+
90
+		return $this->find($user_id);
91
+	}
92
+
93
+	/**
94
+	 * Handle a login request to the application.
95
+	 * 
96
+	 * @param  array   $credentials    
97
+	 * @param  boolean $adminLogin
98
+	 * @return object
99
+	 */
100
+	public function login($credentials, $adminLogin = false)
101
+	{
102
+		if ( ! $user = $this->first(['email' => $credentials['email']])) 
103
+		{
104
+			\ErrorHandler::loginFailed();
105
+		}
106
+		else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
107
+		{
108
+			\ErrorHandler::loginFailed();
109
+		}
110
+		else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
111
+		{
112
+			\ErrorHandler::loginFailed();
113
+		}
114
+		else if ($user->blocked)
115
+		{
116
+			\ErrorHandler::userIsBlocked();
117
+		}
118
+
119
+		return $user;
120
+	}
121
+
122
+	/**
123
+	 * Handle a social login request of the none admin to the application.
124
+	 * 
125
+	 * @param  array   $credentials
126
+	 * @return array
127
+	 */
128
+	public function loginSocial($credentials)
129
+	{
130
+		$access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
131
+		$user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
132
+
133
+		if ( ! $user->email)
134
+		{
135
+			\ErrorHandler::noSocialEmail();
136
+		}
137
+
138
+		if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
139
+		{
140
+			$data = ['email' => $user->email, 'password' => ''];
141
+			return $this->register($data);
142
+		}
143
+		else
144
+		{
145
+			if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
146
+			{
147
+				\ErrorHandler::userAlreadyRegistered();
148
+			}
149
+
150
+			$loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy');
151
+			return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
152
+		}
153
+	}
154 154
     
155
-    /**
156
-     * Handle a registration request.
157
-     * 
158
-     * @param  array $credentials
159
-     * @return array
160
-     */
161
-    public function register($credentials)
162
-    {
163
-        $this->model->create($credentials);
164
-    }
165
-
166
-    /**
167
-     * Block the user.
168
-     *
169
-     * @param  integer $user_id
170
-     * @return object
171
-     */
172
-    public function block($user_id)
173
-    {
174
-        if ( ! $user = $this->find($user_id)) 
175
-        {
176
-            \ErrorHandler::notFound('user');
177
-        }
178
-        if ( ! $this->hasGroup('Admin'))
179
-        {
180
-            \ErrorHandler::noPermissions();
181
-        }
182
-        else if (\Auth::id() == $user_id)
183
-        {
184
-            \ErrorHandler::noPermissions();
185
-        }
186
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
187
-        {
188
-            \ErrorHandler::noPermissions();
189
-        }
190
-
191
-        $user->blocked = 1;
192
-        $user->save();
155
+	/**
156
+	 * Handle a registration request.
157
+	 * 
158
+	 * @param  array $credentials
159
+	 * @return array
160
+	 */
161
+	public function register($credentials)
162
+	{
163
+		$this->model->create($credentials);
164
+	}
165
+
166
+	/**
167
+	 * Block the user.
168
+	 *
169
+	 * @param  integer $user_id
170
+	 * @return object
171
+	 */
172
+	public function block($user_id)
173
+	{
174
+		if ( ! $user = $this->find($user_id)) 
175
+		{
176
+			\ErrorHandler::notFound('user');
177
+		}
178
+		if ( ! $this->hasGroup('Admin'))
179
+		{
180
+			\ErrorHandler::noPermissions();
181
+		}
182
+		else if (\Auth::id() == $user_id)
183
+		{
184
+			\ErrorHandler::noPermissions();
185
+		}
186
+		else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
187
+		{
188
+			\ErrorHandler::noPermissions();
189
+		}
190
+
191
+		$user->blocked = 1;
192
+		$user->save();
193 193
         
194
-        return $user;
195
-    }
196
-
197
-    /**
198
-     * Unblock the user.
199
-     *
200
-     * @param  integer $user_id
201
-     * @return object
202
-     */
203
-    public function unblock($user_id)
204
-    {
205
-        if ( ! $this->hasGroup('Admin'))
206
-        {
207
-            \ErrorHandler::noPermissions();
208
-        }
209
-
210
-        $user          = $this->find($user_id);
211
-        $user->blocked = 0;
212
-        $user->save();
213
-
214
-        return $user;
215
-    }
216
-
217
-    /**
218
-     * Send a reset link to the given user.
219
-     *
220
-     * @param  string  $email
221
-     * @return void
222
-     */
223
-    public function sendReset($email)
224
-    {
225
-        if ( ! $user = $this->model->where('email', $email)->first())
226
-        {
227
-            \ErrorHandler::notFound('email');
228
-        }
229
-
230
-        $url   = $this->config['resetLink'];
231
-        $token = \Password::getRepository()->create($user);
194
+		return $user;
195
+	}
196
+
197
+	/**
198
+	 * Unblock the user.
199
+	 *
200
+	 * @param  integer $user_id
201
+	 * @return object
202
+	 */
203
+	public function unblock($user_id)
204
+	{
205
+		if ( ! $this->hasGroup('Admin'))
206
+		{
207
+			\ErrorHandler::noPermissions();
208
+		}
209
+
210
+		$user          = $this->find($user_id);
211
+		$user->blocked = 0;
212
+		$user->save();
213
+
214
+		return $user;
215
+	}
216
+
217
+	/**
218
+	 * Send a reset link to the given user.
219
+	 *
220
+	 * @param  string  $email
221
+	 * @return void
222
+	 */
223
+	public function sendReset($email)
224
+	{
225
+		if ( ! $user = $this->model->where('email', $email)->first())
226
+		{
227
+			\ErrorHandler::notFound('email');
228
+		}
229
+
230
+		$url   = $this->config['resetLink'];
231
+		$token = \Password::getRepository()->create($user);
232 232
         
233
-        \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
234
-            $m->to($user->email, $user->name)->subject('Your Password Reset Link');
235
-        });
236
-    }
237
-
238
-    /**
239
-     * Reset the given user's password.
240
-     *
241
-     * @param  array  $credentials
242
-     * @return array
243
-     */
244
-    public function resetPassword($credentials)
245
-    {
246
-        $response = \Password::reset($credentials, function ($user, $password) {
247
-            $user->password = $password;
248
-            $user->save();
249
-        });
250
-
251
-        switch ($response) {
252
-            case \Password::PASSWORD_RESET:
253
-                return 'success';
233
+		\Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
234
+			$m->to($user->email, $user->name)->subject('Your Password Reset Link');
235
+		});
236
+	}
237
+
238
+	/**
239
+	 * Reset the given user's password.
240
+	 *
241
+	 * @param  array  $credentials
242
+	 * @return array
243
+	 */
244
+	public function resetPassword($credentials)
245
+	{
246
+		$response = \Password::reset($credentials, function ($user, $password) {
247
+			$user->password = $password;
248
+			$user->save();
249
+		});
250
+
251
+		switch ($response) {
252
+			case \Password::PASSWORD_RESET:
253
+				return 'success';
254 254
                 
255
-            case \Password::INVALID_TOKEN:
256
-                \ErrorHandler::invalidResetToken('token');
257
-
258
-            case \Password::INVALID_PASSWORD:
259
-                \ErrorHandler::invalidResetPassword('email');
260
-
261
-            case \Password::INVALID_USER:
262
-                \ErrorHandler::notFound('user');
263
-
264
-            default:
265
-                \ErrorHandler::generalError();
266
-        }
267
-    }
268
-
269
-    /**
270
-     * Change the logged in user password.
271
-     *
272
-     * @param  array  $credentials
273
-     * @return void
274
-     */
275
-    public function changePassword($credentials)
276
-    {
277
-        $user = \Auth::user();
278
-        if ( ! \Hash::check($credentials['old_password'], $user->password)) 
279
-        {
280
-            \ErrorHandler::invalidOldPassword();
281
-        }
282
-
283
-        $user->password = $credentials['password'];
284
-        $user->save();
285
-    }
286
-
287
-    /**
288
-     * Paginate all users in the given group based on the given conditions.
289
-     * 
290
-     * @param  string  $groupName
291
-     * @param  array   $relations
292
-     * @param  integer $perPage
293
-     * @param  string  $sortBy
294
-     * @param  boolean $desc
295
-     * @return \Illuminate\Http\Response
296
-     */
297
-    public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
298
-    {   
299
-        unset($conditions['page']);
300
-        $conditions = $this->constructConditions($conditions, $this->model);
301
-        $sort       = $desc ? 'desc' : 'asc';
302
-        $model      = call_user_func_array("{$this->getModel()}::with", array($relations));
303
-
304
-        $model->whereHas('groups', function($q) use ($groupName){
305
-            $q->where('name', $groupName);
306
-        });
255
+			case \Password::INVALID_TOKEN:
256
+				\ErrorHandler::invalidResetToken('token');
257
+
258
+			case \Password::INVALID_PASSWORD:
259
+				\ErrorHandler::invalidResetPassword('email');
260
+
261
+			case \Password::INVALID_USER:
262
+				\ErrorHandler::notFound('user');
263
+
264
+			default:
265
+				\ErrorHandler::generalError();
266
+		}
267
+	}
268
+
269
+	/**
270
+	 * Change the logged in user password.
271
+	 *
272
+	 * @param  array  $credentials
273
+	 * @return void
274
+	 */
275
+	public function changePassword($credentials)
276
+	{
277
+		$user = \Auth::user();
278
+		if ( ! \Hash::check($credentials['old_password'], $user->password)) 
279
+		{
280
+			\ErrorHandler::invalidOldPassword();
281
+		}
282
+
283
+		$user->password = $credentials['password'];
284
+		$user->save();
285
+	}
286
+
287
+	/**
288
+	 * Paginate all users in the given group based on the given conditions.
289
+	 * 
290
+	 * @param  string  $groupName
291
+	 * @param  array   $relations
292
+	 * @param  integer $perPage
293
+	 * @param  string  $sortBy
294
+	 * @param  boolean $desc
295
+	 * @return \Illuminate\Http\Response
296
+	 */
297
+	public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
298
+	{   
299
+		unset($conditions['page']);
300
+		$conditions = $this->constructConditions($conditions, $this->model);
301
+		$sort       = $desc ? 'desc' : 'asc';
302
+		$model      = call_user_func_array("{$this->getModel()}::with", array($relations));
303
+
304
+		$model->whereHas('groups', function($q) use ($groupName){
305
+			$q->where('name', $groupName);
306
+		});
307 307
 
308 308
         
309
-        if (count($conditions['conditionValues']))
310
-        {
311
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
312
-        }
313
-
314
-        if ($perPage) 
315
-        {
316
-            return $model->orderBy($sortBy, $sort)->paginate($perPage);
317
-        }
318
-
319
-        return $model->orderBy($sortBy, $sort)->get();
320
-    }
321
-
322
-    /**
323
-     * Save the given data to the logged in user.
324
-     *
325
-     * @param  array $credentials
326
-     * @return void
327
-     */
328
-    public function saveProfile($data) 
329
-    {
330
-        $data['id'] = \Auth::id();
331
-        $this->save($data);
332
-    }
333
-
334
-    /**
335
-     * Ensure access token hasn't expired or revoked.
336
-     * 
337
-     * @param  string $accessToken
338
-     * @return boolean
339
-     */
340
-    public function accessTokenExpiredOrRevoked($accessToken)
341
-    {
342
-
343
-        $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface');
344
-        $data = new ValidationData();
345
-        $data->setCurrentTime(time());
346
-
347
-        if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
348
-        {
349
-            return true;
350
-        }
351
-
352
-        return false;
353
-    }
309
+		if (count($conditions['conditionValues']))
310
+		{
311
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
312
+		}
313
+
314
+		if ($perPage) 
315
+		{
316
+			return $model->orderBy($sortBy, $sort)->paginate($perPage);
317
+		}
318
+
319
+		return $model->orderBy($sortBy, $sort)->get();
320
+	}
321
+
322
+	/**
323
+	 * Save the given data to the logged in user.
324
+	 *
325
+	 * @param  array $credentials
326
+	 * @return void
327
+	 */
328
+	public function saveProfile($data) 
329
+	{
330
+		$data['id'] = \Auth::id();
331
+		$this->save($data);
332
+	}
333
+
334
+	/**
335
+	 * Ensure access token hasn't expired or revoked.
336
+	 * 
337
+	 * @param  string $accessToken
338
+	 * @return boolean
339
+	 */
340
+	public function accessTokenExpiredOrRevoked($accessToken)
341
+	{
342
+
343
+		$accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface');
344
+		$data = new ValidationData();
345
+		$data->setCurrentTime(time());
346
+
347
+		if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
348
+		{
349
+			return true;
350
+		}
351
+
352
+		return false;
353
+	}
354 354
 }
Please login to merge, or discard this patch.