Completed
Push — master ( f3277c...b5dbed )
by Sherif
02:26
created
Database/Migrations/2016_01_24_111942_push_notifications_devices.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 			$table->unique(array('device_token', 'device_type'));
22 22
 			$table->softDeletes();
23 23
 			$table->timestamps();
24
-        });
24
+		});
25 25
 	}
26 26
 
27 27
 	/**
Please login to merge, or discard this patch.
src/lang/en/notifications.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your notification messages.
7
-     */
5
+	/**
6
+	 * Here goes your notification messages.
7
+	 */
8 8
 
9 9
 ];
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/GroupRepository.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,6 +29,6 @@
 block discarded – undo
29 29
 			$group->permissions()->attach($permissionIds);
30 30
 		});
31 31
 
32
-        return $this->find($groupId);
32
+		return $this->find($groupId);
33 33
 	}
34 34
 }
Please login to merge, or discard this patch.
src/Modules/V1/Reporting/Repositories/ReportRepository.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -4,66 +4,66 @@
 block discarded – undo
4 4
 
5 5
 class ReportRepository extends AbstractRepository
6 6
 {
7
-    /**
8
-     * Return the model full namespace.
9
-     * 
10
-     * @return string
11
-     */
12
-    protected function getModel()
13
-    {
14
-        return 'App\Modules\V1\Reporting\Report';
15
-    }
7
+	/**
8
+	 * Return the model full namespace.
9
+	 * 
10
+	 * @return string
11
+	 */
12
+	protected function getModel()
13
+	{
14
+		return 'App\Modules\V1\Reporting\Report';
15
+	}
16 16
 
17
-    /**
18
-     * Render the given report db view based on the given
19
-     * condition.
20
-     *
21
-     * @param  string  $reportName
22
-     * @param  array   $conditions array of conditions
23
-     * @param  integer $perPage
24
-     * @param  array   $relations
25
-     * @return object
26
-     */
27
-    public function getReport($reportName, $conditions = false, $perPage = 0, $relations = [])
28
-    {
29
-        /**
30
-         * Fetch the report from db.
31
-         */
32
-        $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model);
33
-        $report           = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($reportConditions['conditionString'], $reportConditions['conditionValues'])->first();
17
+	/**
18
+	 * Render the given report db view based on the given
19
+	 * condition.
20
+	 *
21
+	 * @param  string  $reportName
22
+	 * @param  array   $conditions array of conditions
23
+	 * @param  integer $perPage
24
+	 * @param  array   $relations
25
+	 * @return object
26
+	 */
27
+	public function getReport($reportName, $conditions = false, $perPage = 0, $relations = [])
28
+	{
29
+		/**
30
+		 * Fetch the report from db.
31
+		 */
32
+		$reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model);
33
+		$report           = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($reportConditions['conditionString'], $reportConditions['conditionValues'])->first();
34 34
         
35
-        /**
36
-         * Check report existance and permission.
37
-         */
38
-        if ( ! $report) 
39
-        {
40
-            \ErrorHandler::notFound('report');
41
-        }
42
-        else if ( ! \Core::users()->can($report->view_name, 'reports'))
43
-        {
44
-            \ErrorHandler::noPermissions();
45
-        }
35
+		/**
36
+		 * Check report existance and permission.
37
+		 */
38
+		if ( ! $report) 
39
+		{
40
+			\ErrorHandler::notFound('report');
41
+		}
42
+		else if ( ! \Core::users()->can($report->view_name, 'reports'))
43
+		{
44
+			\ErrorHandler::noPermissions();
45
+		}
46 46
 
47
-        /**
48
-         * Fetch data from the report based on the given conditions.
49
-         */
50
-        $report = \DB::table($report->view_name);
51
-        unset($conditions['page']);
52
-        if (count($conditions))
53
-        {
54
-            $conditions = $this->constructConditions($conditions, $this->model);
55
-            $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);   
56
-        }
57
-        /**
58
-         * Paginate or all data.
59
-         */
60
-        if ($perPage) 
61
-        {
62
-            return $report->paginate($perPage);
63
-        }
64
-        else
65
-        {
66
-            return $report->get();  
67
-        }
68
-    }
47
+		/**
48
+		 * Fetch data from the report based on the given conditions.
49
+		 */
50
+		$report = \DB::table($report->view_name);
51
+		unset($conditions['page']);
52
+		if (count($conditions))
53
+		{
54
+			$conditions = $this->constructConditions($conditions, $this->model);
55
+			$report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);   
56
+		}
57
+		/**
58
+		 * Paginate or all data.
59
+		 */
60
+		if ($perPage) 
61
+		{
62
+			return $report->paginate($perPage);
63
+		}
64
+		else
65
+		{
66
+			return $report->get();  
67
+		}
68
+	}
69 69
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/AbstractRepositories/AbstractRepositoryContainer.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -4,39 +4,39 @@
 block discarded – undo
4 4
 
5 5
 abstract class AbstractRepositoryContainer implements RepositoryContainerInterface
6 6
 {
7
-    /**
8
-     * Construct the repository class name based on
9
-     * the method name called, search in the 
10
-     * given namespaces for the class and 
11
-     * return an instance.
12
-     * 
13
-     * @param  string $name the called method name
14
-     * @param  array  $arguments the method arguments
15
-     * @return object
16
-     */
17
-    public function __call($name, $arguments)
18
-    {
19
-        foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
-        {
21
-            $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
-            if (class_exists($class)) 
23
-            {
24
-                \App::singleton($class, function ($app) use ($class) {
7
+	/**
8
+	 * Construct the repository class name based on
9
+	 * the method name called, search in the 
10
+	 * given namespaces for the class and 
11
+	 * return an instance.
12
+	 * 
13
+	 * @param  string $name the called method name
14
+	 * @param  array  $arguments the method arguments
15
+	 * @return object
16
+	 */
17
+	public function __call($name, $arguments)
18
+	{
19
+		foreach ($this->getRepoNameSpace() as $repoNameSpace) 
20
+		{
21
+			$class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository';
22
+			if (class_exists($class)) 
23
+			{
24
+				\App::singleton($class, function ($app) use ($class) {
25 25
 
26
-                    return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
-                });
26
+					return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']);
27
+				});
28 28
 
29
-                return \App::make($class);
30
-            }
31
-        }
32
-    }
29
+				return \App::make($class);
30
+			}
31
+		}
32
+	}
33 33
 
34
-     /**
35
-     * Abstract methods that return the necessary 
36
-     * information (repositories namespaces)
37
-     * needed to preform the previous actions.
38
-     * 
39
-     * @return array
40
-     */
41
-    abstract protected function getRepoNameSpace();
34
+	 /**
35
+	  * Abstract methods that return the necessary 
36
+	  * information (repositories namespaces)
37
+	  * needed to preform the previous actions.
38
+	  * 
39
+	  * @return array
40
+	  */
41
+	abstract protected function getRepoNameSpace();
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Database/Migrations/2016_01_24_123630_settings.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('settings', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('key',100)->unique();
19
-            $table->text('value')->nullable();
20
-            $table->softDeletes();
21
-            $table->timestamps();
22
-        });
16
+			$table->increments('id');
17
+			$table->string('name',100);
18
+			$table->string('key',100)->unique();
19
+			$table->text('value')->nullable();
20
+			$table->softDeletes();
21
+			$table->timestamps();
22
+		});
23 23
 	}
24 24
 
25 25
 	/**
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/SettingsController.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@
 block discarded – undo
8 8
 
9 9
 class SettingsController 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               = 'settings';
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               = 'settings';
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|string|max:100',
25
-    'value' => 'required|string'
26
-    ];
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|string|max:100',
25
+	'value' => 'required|string'
26
+	];
27 27
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Decorators/CachingDecorator.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -2,92 +2,92 @@
 block discarded – undo
2 2
 
3 3
 class CachingDecorator
4 4
 {
5
-    /**
6
-     * The repo implementation.
7
-     * 
8
-     * @var string
9
-     */
10
-    protected $repo;
5
+	/**
6
+	 * The repo implementation.
7
+	 * 
8
+	 * @var string
9
+	 */
10
+	protected $repo;
11 11
 
12
-    /**
13
-     * The cache implementation.
14
-     * 
15
-     * @var object
16
-     */
17
-    protected $cache;
12
+	/**
13
+	 * The cache implementation.
14
+	 * 
15
+	 * @var object
16
+	 */
17
+	protected $cache;
18 18
 
19
-    /**
20
-     * The model implementation.
21
-     * 
22
-     * @var string
23
-     */
24
-    public $model;
19
+	/**
20
+	 * The model implementation.
21
+	 * 
22
+	 * @var string
23
+	 */
24
+	public $model;
25 25
 
26
-    /**
27
-     * The cacheConfig implementation.
28
-     * 
29
-     * @var array
30
-     */
31
-    public $cacheConfig;
26
+	/**
27
+	 * The cacheConfig implementation.
28
+	 * 
29
+	 * @var array
30
+	 */
31
+	public $cacheConfig;
32 32
     
33
-    /**
34
-     * Create new CachingDecorator instance.
35
-     */
36
-    public function __construct($repo, $cache)
37
-    {   
38
-        $this->repo  = $repo;
39
-        $this->cache = $cache;
40
-        $this->model = get_class($this->repo->model);
41
-    }
33
+	/**
34
+	 * Create new CachingDecorator instance.
35
+	 */
36
+	public function __construct($repo, $cache)
37
+	{   
38
+		$this->repo  = $repo;
39
+		$this->cache = $cache;
40
+		$this->model = get_class($this->repo->model);
41
+	}
42 42
 
43
-    /**
44
-     * Handle the cache mechanism for the called method
45
-     * based the configurations.
46
-     * 
47
-     * @param  string $name the called method name
48
-     * @param  array  $arguments the method arguments
49
-     * @return object
50
-     */
51
-    public function __call($name, $arguments)
52
-    {
53
-        $this->setCacheConfig($name);
43
+	/**
44
+	 * Handle the cache mechanism for the called method
45
+	 * based the configurations.
46
+	 * 
47
+	 * @param  string $name the called method name
48
+	 * @param  array  $arguments the method arguments
49
+	 * @return object
50
+	 */
51
+	public function __call($name, $arguments)
52
+	{
53
+		$this->setCacheConfig($name);
54 54
 
55
-        if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
-        {
57
-            $page     = \Request::get('page') ?? '1';
58
-            $cacheKey = $name . $page . serialize($arguments);
59
-            return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
-                return call_user_func_array([$this->repo, $name], $arguments);
61
-            });
62
-        }
63
-        else if ($this->cacheConfig)
64
-        {
65
-            $this->cache->tags($this->cacheConfig)->flush();
66
-            return call_user_func_array([$this->repo, $name], $arguments);
67
-        }
55
+		if ($this->cacheConfig && $this->cacheConfig == 'cache') 
56
+		{
57
+			$page     = \Request::get('page') ?? '1';
58
+			$cacheKey = $name . $page . serialize($arguments);
59
+			return $this->cache->tags([$this->model])->rememberForever($cacheKey, function() use ($arguments, $name) {
60
+				return call_user_func_array([$this->repo, $name], $arguments);
61
+			});
62
+		}
63
+		else if ($this->cacheConfig)
64
+		{
65
+			$this->cache->tags($this->cacheConfig)->flush();
66
+			return call_user_func_array([$this->repo, $name], $arguments);
67
+		}
68 68
 
69
-        return call_user_func_array([$this->repo, $name], $arguments);
70
-    }
69
+		return call_user_func_array([$this->repo, $name], $arguments);
70
+	}
71 71
 
72
-    /**
73
-     * Set cache config based on the called method.
74
-     * 
75
-     * @param  string $name
76
-     * @return void
77
-     */
78
-    private function setCacheConfig($name)
79
-    {
80
-        $config            = \CoreConfig::getConfig();
81
-        $cacheConfig       = array_key_exists($this->model, $config['cacheConfig']) ? $config['cacheConfig'][$this->model] : false;
82
-        $this->cacheConfig = false;
72
+	/**
73
+	 * Set cache config based on the called method.
74
+	 * 
75
+	 * @param  string $name
76
+	 * @return void
77
+	 */
78
+	private function setCacheConfig($name)
79
+	{
80
+		$config            = \CoreConfig::getConfig();
81
+		$cacheConfig       = array_key_exists($this->model, $config['cacheConfig']) ? $config['cacheConfig'][$this->model] : false;
82
+		$this->cacheConfig = false;
83 83
 
84
-        if (in_array($cacheConfig['cache'], $name))
85
-        {
86
-            $this->cacheConfig = 'cache';
87
-        }
88
-        else if (in_array($cacheConfig['clear'], $name))
89
-        {
90
-            $this->cacheConfig = $cacheConfig['clear'][$name];
91
-        }
92
-    }
84
+		if (in_array($cacheConfig['cache'], $name))
85
+		{
86
+			$this->cacheConfig = 'cache';
87
+		}
88
+		else if (in_array($cacheConfig['clear'], $name))
89
+		{
90
+			$this->cacheConfig = $cacheConfig['clear'][$name];
91
+		}
92
+	}
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -6,297 +6,297 @@
 block discarded – undo
6 6
 
7 7
 class BaseApiController extends Controller
8 8
 {
9
-    /**
10
-     * The model implementation.
11
-     * 
12
-     * @var string
13
-     */
14
-    protected $model;
9
+	/**
10
+	 * The model implementation.
11
+	 * 
12
+	 * @var string
13
+	 */
14
+	protected $model;
15 15
 
16
-    /**
17
-     * The config implementation.
18
-     * 
19
-     * @var array
20
-     */
21
-    protected $config;
16
+	/**
17
+	 * The config implementation.
18
+	 * 
19
+	 * @var array
20
+	 */
21
+	protected $config;
22 22
 
23
-    /**
24
-     * The relations implementation.
25
-     * 
26
-     * @var array
27
-     */
28
-    protected $relations;
23
+	/**
24
+	 * The relations implementation.
25
+	 * 
26
+	 * @var array
27
+	 */
28
+	protected $relations;
29 29
 
30
-    public function __construct()
31
-    {        
32
-        $this->config              = \CoreConfig::getConfig();
33
-        $this->model               = property_exists($this, 'model') ? $this->model : false;
34
-        $this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
-        $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
-        $route                     = explode('@',\Route::currentRouteAction())[1];
30
+	public function __construct()
31
+	{        
32
+		$this->config              = \CoreConfig::getConfig();
33
+		$this->model               = property_exists($this, 'model') ? $this->model : false;
34
+		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
+		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
+		$route                     = explode('@',\Route::currentRouteAction())[1];
38 38
 
39
-        $this->checkPermission($route);
40
-        $this->setRelations($route);
41
-        $this->setSessions();
42
-    }
39
+		$this->checkPermission($route);
40
+		$this->setRelations($route);
41
+		$this->setSessions();
42
+	}
43 43
 
44
-    /**
45
-     * Fetch all records with relations from model repository.
46
-     * 
47
-     * @param  string  $sortBy
48
-     * @param  boolean $desc
49
-     * @return \Illuminate\Http\Response
50
-     */
51
-    public function index($sortBy = 'created_at', $desc = 1) 
52
-    {
53
-        if ($this->model)
54
-        {
55
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($this->relations, $sortBy, $desc), 200);
56
-        }
57
-    }
44
+	/**
45
+	 * Fetch all records with relations from model repository.
46
+	 * 
47
+	 * @param  string  $sortBy
48
+	 * @param  boolean $desc
49
+	 * @return \Illuminate\Http\Response
50
+	 */
51
+	public function index($sortBy = 'created_at', $desc = 1) 
52
+	{
53
+		if ($this->model)
54
+		{
55
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($this->relations, $sortBy, $desc), 200);
56
+		}
57
+	}
58 58
 
59
-    /**
60
-     * Fetch the single object with relations from model repository.
61
-     * 
62
-     * @param  integer $id
63
-     * @return \Illuminate\Http\Response
64
-     */
65
-    public function find($id) 
66
-    {
67
-        if ($this->model) 
68
-        {
69
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $this->relations), 200);
70
-        }
71
-    }
59
+	/**
60
+	 * Fetch the single object with relations from model repository.
61
+	 * 
62
+	 * @param  integer $id
63
+	 * @return \Illuminate\Http\Response
64
+	 */
65
+	public function find($id) 
66
+	{
67
+		if ($this->model) 
68
+		{
69
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $this->relations), 200);
70
+		}
71
+	}
72 72
 
73
-    /**
74
-     * Paginate all records with relations from model repository
75
-     * that matche the given query.
76
-     * 
77
-     * @param  string  $query
78
-     * @param  integer $perPage
79
-     * @param  string  $sortBy
80
-     * @param  boolean $desc
81
-     * @return \Illuminate\Http\Response
82
-     */
83
-    public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
84
-    {
85
-        if ($this->model) 
86
-        {
87
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
88
-        }
89
-    }
73
+	/**
74
+	 * Paginate all records with relations from model repository
75
+	 * that matche the given query.
76
+	 * 
77
+	 * @param  string  $query
78
+	 * @param  integer $perPage
79
+	 * @param  string  $sortBy
80
+	 * @param  boolean $desc
81
+	 * @return \Illuminate\Http\Response
82
+	 */
83
+	public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
84
+	{
85
+		if ($this->model) 
86
+		{
87
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
88
+		}
89
+	}
90 90
 
91
-    /**
92
-     * Fetch records from the storage based on the given
93
-     * condition.
94
-     * 
95
-     * @param  \Illuminate\Http\Request  $request
96
-     * @param  string  $sortBy
97
-     * @param  boolean $desc
98
-     * @return \Illuminate\Http\Response
99
-     */
100
-    public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
101
-    {
102
-        if ($this->model) 
103
-        {
104
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
105
-        }
106
-    }
91
+	/**
92
+	 * Fetch records from the storage based on the given
93
+	 * condition.
94
+	 * 
95
+	 * @param  \Illuminate\Http\Request  $request
96
+	 * @param  string  $sortBy
97
+	 * @param  boolean $desc
98
+	 * @return \Illuminate\Http\Response
99
+	 */
100
+	public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
101
+	{
102
+		if ($this->model) 
103
+		{
104
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
105
+		}
106
+	}
107 107
 
108
-    /**
109
-     * Fetch the first record from the storage based on the given
110
-     * condition.
111
-     * 
112
-     * @param  \Illuminate\Http\Request  $request
113
-     * @return \Illuminate\Http\Response
114
-     */
115
-    public function first(Request $request) 
116
-    {
117
-        if ($this->model) 
118
-        {
119
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $this->relations), 200);
120
-        }
121
-    }
108
+	/**
109
+	 * Fetch the first record from the storage based on the given
110
+	 * condition.
111
+	 * 
112
+	 * @param  \Illuminate\Http\Request  $request
113
+	 * @return \Illuminate\Http\Response
114
+	 */
115
+	public function first(Request $request) 
116
+	{
117
+		if ($this->model) 
118
+		{
119
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $this->relations), 200);
120
+		}
121
+	}
122 122
 
123
-    /**
124
-     * Paginate all records with relations from model repository.
125
-     * 
126
-     * @param  integer $perPage
127
-     * @param  string  $sortBy
128
-     * @param  boolean $desc
129
-     * @return \Illuminate\Http\Response
130
-     */
131
-    public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
132
-    {
133
-        if ($this->model) 
134
-        {
135
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $this->relations, $sortBy, $desc), 200);
136
-        }
137
-    }
123
+	/**
124
+	 * Paginate all records with relations from model repository.
125
+	 * 
126
+	 * @param  integer $perPage
127
+	 * @param  string  $sortBy
128
+	 * @param  boolean $desc
129
+	 * @return \Illuminate\Http\Response
130
+	 */
131
+	public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
132
+	{
133
+		if ($this->model) 
134
+		{
135
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $this->relations, $sortBy, $desc), 200);
136
+		}
137
+	}
138 138
 
139
-    /**
140
-     * Fetch all records with relations based on
141
-     * the given condition from storage in pages.
142
-     * 
143
-     * @param  \Illuminate\Http\Request  $request
144
-     * @param  integer $perPage
145
-     * @param  string  $sortBy
146
-     * @param  boolean $desc
147
-     * @return \Illuminate\Http\Response
148
-     */
149
-    public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
150
-    {
151
-        if ($this->model) 
152
-        {
153
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
154
-        }
155
-    }
139
+	/**
140
+	 * Fetch all records with relations based on
141
+	 * the given condition from storage in pages.
142
+	 * 
143
+	 * @param  \Illuminate\Http\Request  $request
144
+	 * @param  integer $perPage
145
+	 * @param  string  $sortBy
146
+	 * @param  boolean $desc
147
+	 * @return \Illuminate\Http\Response
148
+	 */
149
+	public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
150
+	{
151
+		if ($this->model) 
152
+		{
153
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
154
+		}
155
+	}
156 156
 
157
-    /**
158
-     * Save the given model to repository.
159
-     * 
160
-     * @param  \Illuminate\Http\Request  $request
161
-     * @return \Illuminate\Http\Response
162
-     */
163
-    public function save(Request $request) 
164
-    {
165
-        foreach ($this->validationRules as &$rule) 
166
-        {
167
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
-            {
169
-                $rule .= ',deleted_at,NULL';
170
-            }
157
+	/**
158
+	 * Save the given model to repository.
159
+	 * 
160
+	 * @param  \Illuminate\Http\Request  $request
161
+	 * @return \Illuminate\Http\Response
162
+	 */
163
+	public function save(Request $request) 
164
+	{
165
+		foreach ($this->validationRules as &$rule) 
166
+		{
167
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
168
+			{
169
+				$rule .= ',deleted_at,NULL';
170
+			}
171 171
 
172
-            if ($request->has('id')) 
173
-            {
174
-                $rule = str_replace('{id}', $request->get('id'), $rule);
175
-            }
176
-            else
177
-            {
178
-                $rule = str_replace(',{id}', '', $rule);
179
-            }
180
-        }
172
+			if ($request->has('id')) 
173
+			{
174
+				$rule = str_replace('{id}', $request->get('id'), $rule);
175
+			}
176
+			else
177
+			{
178
+				$rule = str_replace(',{id}', '', $rule);
179
+			}
180
+		}
181 181
         
182
-        $this->validate($request, $this->validationRules);
182
+		$this->validate($request, $this->validationRules);
183 183
 
184
-        if ($this->model) 
185
-        {
186
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
-        }
188
-    }
184
+		if ($this->model) 
185
+		{
186
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * Delete by the given id from model repository.
192
-     * 
193
-     * @param  integer  $id
194
-     * @return \Illuminate\Http\Response
195
-     */
196
-    public function delete($id) 
197
-    {
198
-        if ($this->model) 
199
-        {
200
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
-        }
202
-    }
190
+	/**
191
+	 * Delete by the given id from model repository.
192
+	 * 
193
+	 * @param  integer  $id
194
+	 * @return \Illuminate\Http\Response
195
+	 */
196
+	public function delete($id) 
197
+	{
198
+		if ($this->model) 
199
+		{
200
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
201
+		}
202
+	}
203 203
 
204
-    /**
205
-     * Return the deleted models in pages based on the given conditions.
206
-     *
207
-     * @param  \Illuminate\Http\Request  $request
208
-     * @param  integer $perPage
209
-     * @param  string  $sortBy
210
-     * @param  boolean $desc
211
-     * @return \Illuminate\Http\Response
212
-     */
213
-    public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
214
-    {
215
-        return \Response::json(call_user_func_array("\Core::{$this->model}", [])->deleted($request->all(), $perPage, $sortBy, $desc), 200);
216
-    }
204
+	/**
205
+	 * Return the deleted models in pages based on the given conditions.
206
+	 *
207
+	 * @param  \Illuminate\Http\Request  $request
208
+	 * @param  integer $perPage
209
+	 * @param  string  $sortBy
210
+	 * @param  boolean $desc
211
+	 * @return \Illuminate\Http\Response
212
+	 */
213
+	public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
214
+	{
215
+		return \Response::json(call_user_func_array("\Core::{$this->model}", [])->deleted($request->all(), $perPage, $sortBy, $desc), 200);
216
+	}
217 217
 
218
-    /**
219
-     * Restore the deleted model.
220
-     * 
221
-     * @param  integer  $id
222
-     * @return \Illuminate\Http\Response
223
-     */
224
-    public function restore($id) 
225
-    {
226
-        if ($this->model) 
227
-        {
228
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->restore($id), 200);
229
-        }
230
-    }
218
+	/**
219
+	 * Restore the deleted model.
220
+	 * 
221
+	 * @param  integer  $id
222
+	 * @return \Illuminate\Http\Response
223
+	 */
224
+	public function restore($id) 
225
+	{
226
+		if ($this->model) 
227
+		{
228
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->restore($id), 200);
229
+		}
230
+	}
231 231
 
232
-    /**
233
-     * Check if the logged in user can do the given permission.
234
-     * 
235
-     * @param  string $permission
236
-     * @return void
237
-     */
238
-    private function checkPermission($permission)
239
-    {
240
-        $permission = $permission !== 'index' ? $permission : 'list';
241
-        if ( ! in_array($permission, $this->skipLoginCheck)) 
242
-        {
243
-            $user = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id);
244
-            if ($user->blocked)
245
-            {
246
-                \ErrorHandler::userIsBlocked();
247
-            }
232
+	/**
233
+	 * Check if the logged in user can do the given permission.
234
+	 * 
235
+	 * @param  string $permission
236
+	 * @return void
237
+	 */
238
+	private function checkPermission($permission)
239
+	{
240
+		$permission = $permission !== 'index' ? $permission : 'list';
241
+		if ( ! in_array($permission, $this->skipLoginCheck)) 
242
+		{
243
+			$user = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id);
244
+			if ($user->blocked)
245
+			{
246
+				\ErrorHandler::userIsBlocked();
247
+			}
248 248
             
249
-            if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
250
-            {
251
-                \ErrorHandler::noPermissions();
252
-            }
253
-        }
254
-    }
249
+			if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
250
+			{
251
+				\ErrorHandler::noPermissions();
252
+			}
253
+		}
254
+	}
255 255
 
256
-    /**
257
-     * Set sessions based on the given headers in the request.
258
-     * 
259
-     * @return void
260
-     */
261
-    private function setSessions()
262
-    {
263
-        \Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
256
+	/**
257
+	 * Set sessions based on the given headers in the request.
258
+	 * 
259
+	 * @return void
260
+	 */
261
+	private function setSessions()
262
+	{
263
+		\Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
264 264
 
265
-        $locale = \Request::header('locale');
266
-        switch ($locale) 
267
-        {
268
-            case 'en':
269
-            \App::setLocale('en');
270
-            \Session::put('locale', 'en');
271
-            break;
265
+		$locale = \Request::header('locale');
266
+		switch ($locale) 
267
+		{
268
+			case 'en':
269
+			\App::setLocale('en');
270
+			\Session::put('locale', 'en');
271
+			break;
272 272
 
273
-            case 'ar':
274
-            \App::setLocale('ar');
275
-            \Session::put('locale', 'ar');
276
-            break;
273
+			case 'ar':
274
+			\App::setLocale('ar');
275
+			\Session::put('locale', 'ar');
276
+			break;
277 277
 
278
-            case 'all':
279
-            \App::setLocale('en');
280
-            \Session::put('locale', 'all');
281
-            break;
278
+			case 'all':
279
+			\App::setLocale('en');
280
+			\Session::put('locale', 'all');
281
+			break;
282 282
 
283
-            default:
284
-            \App::setLocale('en');
285
-            \Session::put('locale', 'en');
286
-            break;
287
-        }
288
-    }
283
+			default:
284
+			\App::setLocale('en');
285
+			\Session::put('locale', 'en');
286
+			break;
287
+		}
288
+	}
289 289
 
290
-    /**
291
-     * Set relation based on the called api.
292
-     * 
293
-     * @param  string $route
294
-     * @return void
295
-     */
296
-    private function setRelations($route)
297
-    {
298
-        $route           = $route !== 'index' ? $route : 'list';
299
-        $relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
300
-        $this->relations = $relations && $relations[$route] ? $relations[$route] : [];
301
-    }
290
+	/**
291
+	 * Set relation based on the called api.
292
+	 * 
293
+	 * @param  string $route
294
+	 * @return void
295
+	 */
296
+	private function setRelations($route)
297
+	{
298
+		$route           = $route !== 'index' ? $route : 'list';
299
+		$relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
300
+		$this->relations = $relations && $relations[$route] ? $relations[$route] : [];
301
+	}
302 302
 }
Please login to merge, or discard this patch.