Completed
Push — master ( 2f9ece...c4baa4 )
by Sherif
05:12 queued 45s
created
src/Modules/Acl/Database/Migrations/2016_01_05_130506_permissions.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,21 +12,21 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-        Schema::create('permissions', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('model',100);
19
-            $table->softDeletes();
20
-            $table->timestamps();
21
-            $table->unique(array('name', 'model'));
22
-        });
23
-        Schema::create('groups_permissions', function (Blueprint $table) {
24
-            $table->increments('id');
25
-            $table->integer('group_id');
26
-            $table->integer('permission_id');
27
-            $table->softDeletes();
28
-            $table->timestamps();
29
-        });
15
+		Schema::create('permissions', function (Blueprint $table) {
16
+			$table->increments('id');
17
+			$table->string('name',100);
18
+			$table->string('model',100);
19
+			$table->softDeletes();
20
+			$table->timestamps();
21
+			$table->unique(array('name', 'model'));
22
+		});
23
+		Schema::create('groups_permissions', function (Blueprint $table) {
24
+			$table->increments('id');
25
+			$table->integer('group_id');
26
+			$table->integer('permission_id');
27
+			$table->softDeletes();
28
+			$table->timestamps();
29
+		});
30 30
 	}
31 31
 
32 32
 	/**
Please login to merge, or discard this patch.
src/Modules/Acl/Database/Migrations/2015_12_22_145819_groups.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('groups', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100)->unique();
18
-            $table->softDeletes();
19
-            $table->timestamps();
20
-        });
16
+			$table->increments('id');
17
+			$table->string('name',100)->unique();
18
+			$table->softDeletes();
19
+			$table->timestamps();
20
+		});
21 21
         
22
-        Schema::create('users_groups', function (Blueprint $table) {
23
-            $table->increments('id');
24
-            $table->integer('user_id');
25
-            $table->integer('group_id');
26
-            $table->softDeletes();
27
-            $table->timestamps();
28
-        });
22
+		Schema::create('users_groups', function (Blueprint $table) {
23
+			$table->increments('id');
24
+			$table->integer('user_id');
25
+			$table->integer('group_id');
26
+			$table->softDeletes();
27
+			$table->timestamps();
28
+		});
29 29
 	}
30 30
 
31 31
 	/**
Please login to merge, or discard this patch.
src/Modules/Acl/AclPermission.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@
 block discarded – undo
5 5
 
6 6
 class AclPermission extends Model {
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'permissions';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['name', 'model'];
14
-
15
-    public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
19
-
20
-    public function getUpdatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
-    }
24
-
25
-    public function getDeletedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
-    }
8
+	use SoftDeletes;
9
+	protected $table    = 'permissions';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['name', 'model'];
14
+
15
+	public function getCreatedAtAttribute($value)
16
+	{
17
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
+	}
19
+
20
+	public function getUpdatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
+	}
24
+
25
+	public function getDeletedAtAttribute($value)
26
+	{
27
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
+	}
29 29
     
30
-    public function groups()
31
-    {
32
-        return $this->belongsToMany('\App\Modules\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
33
-    }
34
-
35
-    public static function boot()
36
-    {
37
-        parent::boot();
38
-
39
-        AclPermission::deleting(function($permission)
40
-        {
41
-            \DB::table('groups_permissions')
42
-            ->where('permission_id', $permission->id)
43
-            ->update(array('deleted_at' => \DB::raw('NOW()')));
44
-        });
45
-    }
30
+	public function groups()
31
+	{
32
+		return $this->belongsToMany('\App\Modules\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
33
+	}
34
+
35
+	public static function boot()
36
+	{
37
+		parent::boot();
38
+
39
+		AclPermission::deleting(function($permission)
40
+		{
41
+			\DB::table('groups_permissions')
42
+			->where('permission_id', $permission->id)
43
+			->update(array('deleted_at' => \DB::raw('NOW()')));
44
+		});
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/Modules/Acl/AclUser.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -6,74 +6,74 @@
 block discarded – undo
6 6
 
7 7
 class AclUser extends User {
8 8
 
9
-    use SoftDeletes;
10
-    protected $table    = 'users';
11
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
-    protected $hidden   = ['password', 'remember_token','deleted_at'];
13
-    protected $guarded  = ['id'];
14
-    protected $fillable = ['first_name', 'last_name', 'user_name', 'address', 'email', 'password'];
15
-    protected $appends  = ['permissions'];
9
+	use SoftDeletes;
10
+	protected $table    = 'users';
11
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
+	protected $hidden   = ['password', 'remember_token','deleted_at'];
13
+	protected $guarded  = ['id'];
14
+	protected $fillable = ['first_name', 'last_name', 'user_name', 'address', 'email', 'password'];
15
+	protected $appends  = ['permissions'];
16 16
     
17
-    public function getCreatedAtAttribute($value)
18
-    {
19
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
20
-    }
17
+	public function getCreatedAtAttribute($value)
18
+	{
19
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
20
+	}
21 21
 
22
-    public function getUpdatedAtAttribute($value)
23
-    {
24
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
25
-    }
22
+	public function getUpdatedAtAttribute($value)
23
+	{
24
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
25
+	}
26 26
 
27
-    public function getDeletedAtAttribute($value)
28
-    {
29
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
30
-    }
27
+	public function getDeletedAtAttribute($value)
28
+	{
29
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
30
+	}
31 31
 
32
-    /**
33
-     * Encrypt the password attribute before
34
-     * saving it in the storage.
35
-     * 
36
-     * @param string $value 
37
-     */
38
-    public function setPasswordAttribute($value)
39
-    {
40
-        $this->attributes['password'] = bcrypt($value);
41
-    }
32
+	/**
33
+	 * Encrypt the password attribute before
34
+	 * saving it in the storage.
35
+	 * 
36
+	 * @param string $value 
37
+	 */
38
+	public function setPasswordAttribute($value)
39
+	{
40
+		$this->attributes['password'] = bcrypt($value);
41
+	}
42 42
 
43
-    public function logs()
44
-    {
45
-        return $this->hasMany('App\Modules\Logging\Log', 'user_id');
46
-    }
43
+	public function logs()
44
+	{
45
+		return $this->hasMany('App\Modules\Logging\Log', 'user_id');
46
+	}
47 47
 
48
-    public function groups()
49
-    {
50
-        return $this->belongsToMany('\App\Modules\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
51
-    }
48
+	public function groups()
49
+	{
50
+		return $this->belongsToMany('\App\Modules\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
51
+	}
52 52
 
53
-    public function getPermissionsAttribute()
54
-    {
55
-        $permissions = [];
56
-        foreach ($this->groups as $group)
57
-        {
58
-            $group->permissions->each(function ($permission) use (&$permissions){
59
-                $permissions[$permission->model][$permission->id] = $permission->name;
60
-            });
61
-        }
53
+	public function getPermissionsAttribute()
54
+	{
55
+		$permissions = [];
56
+		foreach ($this->groups as $group)
57
+		{
58
+			$group->permissions->each(function ($permission) use (&$permissions){
59
+				$permissions[$permission->model][$permission->id] = $permission->name;
60
+			});
61
+		}
62 62
 
63
-        return \Illuminate\Database\Eloquent\Collection::make($permissions);
64
-    }
63
+		return \Illuminate\Database\Eloquent\Collection::make($permissions);
64
+	}
65 65
 
66
-    public static function boot()
67
-    {
68
-        parent::boot();
66
+	public static function boot()
67
+	{
68
+		parent::boot();
69 69
         
70
-        AclUser::deleting(function($user)
71
-        {
72
-            \DB::table('users_groups')
73
-            ->where('user_id', $user->id)
74
-            ->update(array('deleted_at' => \DB::raw('NOW()')));
70
+		AclUser::deleting(function($user)
71
+		{
72
+			\DB::table('users_groups')
73
+			->where('user_id', $user->id)
74
+			->update(array('deleted_at' => \DB::raw('NOW()')));
75 75
 
76
-            $user->logs()->delete();
77
-        });
78
-    }
76
+			$user->logs()->delete();
77
+		});
78
+	}
79 79
 }
Please login to merge, or discard this patch.
src/Modules/Core/Settings.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,45 +5,45 @@
 block discarded – undo
5 5
 
6 6
 class Settings extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'settings';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id', 'key'];
13
-    protected $fillable = ['name','value'];
8
+	use SoftDeletes;
9
+	protected $table    = 'settings';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id', 'key'];
13
+	protected $fillable = ['name','value'];
14 14
     
15
-    public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
19
-
20
-    public function getUpdatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
-    }
24
-
25
-    public function getDeletedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
-    }
29
-
30
-    public static function boot()
31
-    {
32
-        parent::boot();
33
-
34
-        Settings::creating(function($setting)
35
-        {
36
-            $error = \ErrorHandler::cannotCreateSetting();
37
-            abort($error['status'], $error['message']);
38
-        });
39
-
40
-        Settings::updating(function($setting)
41
-        {
42
-            if ($setting->original['key'] !== $setting->key) 
43
-            {
44
-                $error = \ErrorHandler::cannotUpdateSettingKey();
45
-                abort($error['status'], $error['message']);
46
-            }
47
-        });
48
-    }
15
+	public function getCreatedAtAttribute($value)
16
+	{
17
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
+	}
19
+
20
+	public function getUpdatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
+	}
24
+
25
+	public function getDeletedAtAttribute($value)
26
+	{
27
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
+	}
29
+
30
+	public static function boot()
31
+	{
32
+		parent::boot();
33
+
34
+		Settings::creating(function($setting)
35
+		{
36
+			$error = \ErrorHandler::cannotCreateSetting();
37
+			abort($error['status'], $error['message']);
38
+		});
39
+
40
+		Settings::updating(function($setting)
41
+		{
42
+			if ($setting->original['key'] !== $setting->key) 
43
+			{
44
+				$error = \ErrorHandler::cannotUpdateSettingKey();
45
+				abort($error['status'], $error['message']);
46
+			}
47
+		});
48
+	}
49 49
 }
Please login to merge, or discard this patch.
src/Modules/Core/AbstractRepositories/AbstractRepository.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -7,466 +7,466 @@
 block discarded – undo
7 7
 
8 8
 abstract class AbstractRepository implements RepositoryInterface
9 9
 {
10
-    /**
11
-     * The model implementation.
12
-     * 
13
-     * @var model
14
-     */
15
-    public $model;
10
+	/**
11
+	 * The model implementation.
12
+	 * 
13
+	 * @var model
14
+	 */
15
+	public $model;
16 16
 
17
-    /**
18
-     * The errorHandler implementation.
19
-     * 
20
-     * @var errorHandler
21
-     */
22
-    protected $errorHandler;
17
+	/**
18
+	 * The errorHandler implementation.
19
+	 * 
20
+	 * @var errorHandler
21
+	 */
22
+	protected $errorHandler;
23 23
 
24
-    /**
25
-     * The logs implementation.
26
-     * 
27
-     * @var logs
28
-     */
29
-    protected $logs;
24
+	/**
25
+	 * The logs implementation.
26
+	 * 
27
+	 * @var logs
28
+	 */
29
+	protected $logs;
30 30
 
31
-    /**
32
-     * The config implementation.
33
-     * 
34
-     * @var config
35
-     */
36
-    protected $config;
31
+	/**
32
+	 * The config implementation.
33
+	 * 
34
+	 * @var config
35
+	 */
36
+	protected $config;
37 37
     
38
-    /**
39
-     * Create new AbstractRepository instance.
40
-     */
41
-    public function __construct(ErrorHandler $errorHandler, CoreConfig $config, Log $logs)
42
-    {   
43
-        $this->errorHandler = $errorHandler;
44
-        $this->config       = $config->getConfig();
45
-        $this->logs         = $logs;
46
-        $this->model        = \App::make($this->getModel());
47
-    }
38
+	/**
39
+	 * Create new AbstractRepository instance.
40
+	 */
41
+	public function __construct(ErrorHandler $errorHandler, CoreConfig $config, Log $logs)
42
+	{   
43
+		$this->errorHandler = $errorHandler;
44
+		$this->config       = $config->getConfig();
45
+		$this->logs         = $logs;
46
+		$this->model        = \App::make($this->getModel());
47
+	}
48 48
 
49
-    /**
50
-     * Fetch all records with relations from the storage.
51
-     *
52
-     * @param  array   $relations
53
-     * @param  string  $sortBy
54
-     * @param  boolean $desc
55
-     * @param  array   $columns
56
-     * @return collection
57
-     */
49
+	/**
50
+	 * Fetch all records with relations from the storage.
51
+	 *
52
+	 * @param  array   $relations
53
+	 * @param  string  $sortBy
54
+	 * @param  boolean $desc
55
+	 * @param  array   $columns
56
+	 * @return collection
57
+	 */
58 58
 	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
59 59
 	{
60
-        $sort = $desc ? 'desc' : 'asc';
61
-        return call_user_func_array("{$this->getModel()}::with", array($relations))->orderBy($sortBy, $sort)->get($columns);
60
+		$sort = $desc ? 'desc' : 'asc';
61
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->orderBy($sortBy, $sort)->get($columns);
62 62
 	}
63 63
 
64
-    /**
65
-     * Fetch all records with relations from storage in pages 
66
-     * that matche the given query.
67
-     * 
68
-     * @param  string  $query
69
-     * @param  integer $perPage
70
-     * @param  array   $relations
71
-     * @param  string  $sortBy
72
-     * @param  boolean $desc
73
-     * @param  array   $columns
74
-     * @return collection
75
-     */
76
-    public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
77
-    {
78
-        $model            = call_user_func_array("{$this->getModel()}::with", array($relations));
79
-        $conditionColumns = $this->model->getFillable();
80
-        $sort             = $desc ? 'desc' : 'asc';
64
+	/**
65
+	 * Fetch all records with relations from storage in pages 
66
+	 * that matche the given query.
67
+	 * 
68
+	 * @param  string  $query
69
+	 * @param  integer $perPage
70
+	 * @param  array   $relations
71
+	 * @param  string  $sortBy
72
+	 * @param  boolean $desc
73
+	 * @param  array   $columns
74
+	 * @return collection
75
+	 */
76
+	public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
77
+	{
78
+		$model            = call_user_func_array("{$this->getModel()}::with", array($relations));
79
+		$conditionColumns = $this->model->getFillable();
80
+		$sort             = $desc ? 'desc' : 'asc';
81 81
 
82
-        $model->where(function ($q) use ($query, $conditionColumns, $relations){
83
-            $q->where(\DB::raw('LOWER(CAST(' . array_shift($conditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
84
-            foreach ($conditionColumns as $column) 
85
-            {
86
-                $q->orWhere(\DB::raw('LOWER(CAST(' . $column . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
87
-            }
88
-            foreach ($relations as $relation) 
89
-            {
90
-                $relation = explode('.', $relation)[0];
91
-                if (\Core::$relation()) 
92
-                {
93
-                    $q->orWhereHas($relation, function ($subModel) use ($query, $relation){
82
+		$model->where(function ($q) use ($query, $conditionColumns, $relations){
83
+			$q->where(\DB::raw('LOWER(CAST(' . array_shift($conditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
84
+			foreach ($conditionColumns as $column) 
85
+			{
86
+				$q->orWhere(\DB::raw('LOWER(CAST(' . $column . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
87
+			}
88
+			foreach ($relations as $relation) 
89
+			{
90
+				$relation = explode('.', $relation)[0];
91
+				if (\Core::$relation()) 
92
+				{
93
+					$q->orWhereHas($relation, function ($subModel) use ($query, $relation){
94 94
 
95
-                        $subModel->where(function ($q) use ($query, $relation){
95
+						$subModel->where(function ($q) use ($query, $relation){
96 96
 
97
-                            $subConditionColumns = \Core::$relation()->model->getFillable();
98
-                            $q->where(\DB::raw('LOWER(CAST(' . array_shift($subConditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
99
-                            foreach ($subConditionColumns as $column)
100
-                            {
101
-                                $q->orWhere(\DB::raw('LOWER(CAST(' . $column . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
102
-                            } 
103
-                        });
97
+							$subConditionColumns = \Core::$relation()->model->getFillable();
98
+							$q->where(\DB::raw('LOWER(CAST(' . array_shift($subConditionColumns) . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
99
+							foreach ($subConditionColumns as $column)
100
+							{
101
+								$q->orWhere(\DB::raw('LOWER(CAST(' . $column . ' AS TEXT))'), 'LIKE', '%' . strtolower($query) . '%');
102
+							} 
103
+						});
104 104
 
105
-                    });
106
-                }
107
-            }
108
-        });
105
+					});
106
+				}
107
+			}
108
+		});
109 109
         
110
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
111
-    }
110
+		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
111
+	}
112 112
     
113
-    /**
114
-     * Fetch all records with relations from storage in pages.
115
-     * 
116
-     * @param  integer $perPage
117
-     * @param  array   $relations
118
-     * @param  string  $sortBy
119
-     * @param  boolean $desc
120
-     * @param  array   $columns
121
-     * @return collection
122
-     */
123
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
124
-    {
125
-        $sort = $desc ? 'desc' : 'asc';
126
-        return call_user_func_array("{$this->getModel()}::with", array($relations))->orderBy($sortBy, $sort)->paginate($perPage, $columns);
127
-    }
113
+	/**
114
+	 * Fetch all records with relations from storage in pages.
115
+	 * 
116
+	 * @param  integer $perPage
117
+	 * @param  array   $relations
118
+	 * @param  string  $sortBy
119
+	 * @param  boolean $desc
120
+	 * @param  array   $columns
121
+	 * @return collection
122
+	 */
123
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
124
+	{
125
+		$sort = $desc ? 'desc' : 'asc';
126
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->orderBy($sortBy, $sort)->paginate($perPage, $columns);
127
+	}
128 128
 
129
-    /**
130
-     * Fetch all records with relations based on
131
-     * the given condition from storage in pages.
132
-     * 
133
-     * @param  array   $conditions array of conditions
134
-     * @param  integer $perPage
135
-     * @param  array   $relations
136
-     * @param  string  $sortBy
137
-     * @param  boolean $desc
138
-     * @param  array   $columns
139
-     * @return collection
140
-     */
141
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
142
-    {
143
-        unset($conditions['page']);
144
-        $conditions = $this->constructConditions($conditions);
145
-        $sort       = $desc ? 'desc' : 'asc';
146
-        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
147
-    }
129
+	/**
130
+	 * Fetch all records with relations based on
131
+	 * the given condition from storage in pages.
132
+	 * 
133
+	 * @param  array   $conditions array of conditions
134
+	 * @param  integer $perPage
135
+	 * @param  array   $relations
136
+	 * @param  string  $sortBy
137
+	 * @param  boolean $desc
138
+	 * @param  array   $columns
139
+	 * @return collection
140
+	 */
141
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
142
+	{
143
+		unset($conditions['page']);
144
+		$conditions = $this->constructConditions($conditions);
145
+		$sort       = $desc ? 'desc' : 'asc';
146
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
147
+	}
148 148
     
149
-    /**
150
-     * Save the given model to the storage.
151
-     * 
152
-     * @param  array   $data
153
-     * @param  boolean $saveLog
154
-     * @return object
155
-     */
156
-    public function save(array $data, $saveLog = true)
157
-    {
158
-        $model      = false;
159
-        $modelClass = $this->model;
160
-        $relations  = [];
161
-        $with       = [];
149
+	/**
150
+	 * Save the given model to the storage.
151
+	 * 
152
+	 * @param  array   $data
153
+	 * @param  boolean $saveLog
154
+	 * @return object
155
+	 */
156
+	public function save(array $data, $saveLog = true)
157
+	{
158
+		$model      = false;
159
+		$modelClass = $this->model;
160
+		$relations  = [];
161
+		$with       = [];
162 162
 
163
-        \DB::transaction(function () use (&$model, &$relations, &$with, $data, $saveLog, $modelClass) {
164
-            /**
165
-             * If the id is present in the data then select the model for updating,
166
-             * else create new model.
167
-             * @var array
168
-             */
169
-            $model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
170
-            if ( ! $model) 
171
-            {
172
-                $error = $this->errorHandler->notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
173
-                abort($error['status'], $error['message']);
174
-            }
163
+		\DB::transaction(function () use (&$model, &$relations, &$with, $data, $saveLog, $modelClass) {
164
+			/**
165
+			 * If the id is present in the data then select the model for updating,
166
+			 * else create new model.
167
+			 * @var array
168
+			 */
169
+			$model = array_key_exists('id', $data) ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
170
+			if ( ! $model) 
171
+			{
172
+				$error = $this->errorHandler->notFound(class_basename($modelClass) . ' with id : ' . $data['id']);
173
+				abort($error['status'], $error['message']);
174
+			}
175 175
 
176
-            /**
177
-             * Construct the model object with the given data,
178
-             * and if there is a relation add it to relations array,
179
-             * then save the model.
180
-             */
181
-            foreach ($data as $key => $value) 
182
-            {
183
-                $relation = camel_case($key);
184
-                if (method_exists($model, $relation))
185
-                {
186
-                    $with[] = $relation;
187
-                    if (class_basename($model->$relation) == 'Collection') 
188
-                    {   
189
-                        if ( ! $value || ! count($value)) 
190
-                        {
191
-                            $relations[$relation] = 'delete';
192
-                        }   
193
-                    }
194
-                    if (is_array($value)) 
195
-                    {
196
-                        foreach ($value as $attr => $val) 
197
-                        {
198
-                            $relationBaseModel = \Core::$relation()->model;
199
-                            if (class_basename($model->$relation) == 'Collection')
200
-                            {
201
-                                $relationModel = array_key_exists('id', $val) ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
202
-                                if ( ! $relationModel) 
203
-                                {
204
-                                    $error = $this->errorHandler->notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
205
-                                    abort($error['status'], $error['message']);
206
-                                }
176
+			/**
177
+			 * Construct the model object with the given data,
178
+			 * and if there is a relation add it to relations array,
179
+			 * then save the model.
180
+			 */
181
+			foreach ($data as $key => $value) 
182
+			{
183
+				$relation = camel_case($key);
184
+				if (method_exists($model, $relation))
185
+				{
186
+					$with[] = $relation;
187
+					if (class_basename($model->$relation) == 'Collection') 
188
+					{   
189
+						if ( ! $value || ! count($value)) 
190
+						{
191
+							$relations[$relation] = 'delete';
192
+						}   
193
+					}
194
+					if (is_array($value)) 
195
+					{
196
+						foreach ($value as $attr => $val) 
197
+						{
198
+							$relationBaseModel = \Core::$relation()->model;
199
+							if (class_basename($model->$relation) == 'Collection')
200
+							{
201
+								$relationModel = array_key_exists('id', $val) ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
202
+								if ( ! $relationModel) 
203
+								{
204
+									$error = $this->errorHandler->notFound(class_basename($relationBaseModel) . ' with id : ' . $val['id']);
205
+									abort($error['status'], $error['message']);
206
+								}
207 207
 
208
-                                foreach ($val as $attr => $val) 
209
-                                {
210
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
211
-                                    {
212
-                                        $relationModel->$attr = $val;
213
-                                    }
214
-                                }
215
-                                $relations[$relation][] = $relationModel;
216
-                            }
217
-                            else
218
-                            {
219
-                                if (gettype($val) !== 'object' && gettype($val) !== 'array') 
220
-                                {
221
-                                    $relationModel = array_key_exists('id', $value) ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
222
-                                    if ( ! $relationModel) 
223
-                                    {
224
-                                        $error = $this->errorHandler->notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
225
-                                        abort($error['status'], $error['message']);
226
-                                    }
208
+								foreach ($val as $attr => $val) 
209
+								{
210
+									if (gettype($val) !== 'object' && gettype($val) !== 'array' &&  array_search($attr, $relationModel->getFillable(), true) !== false)
211
+									{
212
+										$relationModel->$attr = $val;
213
+									}
214
+								}
215
+								$relations[$relation][] = $relationModel;
216
+							}
217
+							else
218
+							{
219
+								if (gettype($val) !== 'object' && gettype($val) !== 'array') 
220
+								{
221
+									$relationModel = array_key_exists('id', $value) ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
222
+									if ( ! $relationModel) 
223
+									{
224
+										$error = $this->errorHandler->notFound(class_basename($relationBaseModel) . ' with id : ' . $value['id']);
225
+										abort($error['status'], $error['message']);
226
+									}
227 227
 
228
-                                    if (array_search($attr, $relationModel->getFillable(), true) !== false) 
229
-                                    {
230
-                                        $relationModel->$attr = $val;
231
-                                        $relations[$relation] = $relationModel;
232
-                                    }
233
-                                }
234
-                            }
235
-                        }
236
-                    }
237
-                }
238
-                else if (array_search($key, $model->getFillable(), true) !== false)
239
-                {
240
-                    $model->$key = $value;   
241
-                }
242
-            }
243
-            $model->save();
228
+									if (array_search($attr, $relationModel->getFillable(), true) !== false) 
229
+									{
230
+										$relationModel->$attr = $val;
231
+										$relations[$relation] = $relationModel;
232
+									}
233
+								}
234
+							}
235
+						}
236
+					}
237
+				}
238
+				else if (array_search($key, $model->getFillable(), true) !== false)
239
+				{
240
+					$model->$key = $value;   
241
+				}
242
+			}
243
+			$model->save();
244 244
             
245
-            foreach ($relations as $key => $value) 
246
-            {
247
-                if ($value == 'delete' && $model->$key()->count())
248
-                {
249
-                    $model->$key()->delete();
250
-                }
251
-                else if (gettype($value) == 'array') 
252
-                {
253
-                    $ids = [];
254
-                    foreach ($value as $val) 
255
-                    {
256
-                        switch (class_basename($model->$key())) 
257
-                        {
258
-                            case 'HasMany':
259
-                                $foreignKeyName       = explode('.', $model->$key()->getForeignKey())[1];
260
-                                $val->$foreignKeyName = $model->id;
261
-                                $val->save();
262
-                                $ids[] = $val->id;
263
-                                break;
245
+			foreach ($relations as $key => $value) 
246
+			{
247
+				if ($value == 'delete' && $model->$key()->count())
248
+				{
249
+					$model->$key()->delete();
250
+				}
251
+				else if (gettype($value) == 'array') 
252
+				{
253
+					$ids = [];
254
+					foreach ($value as $val) 
255
+					{
256
+						switch (class_basename($model->$key())) 
257
+						{
258
+							case 'HasMany':
259
+								$foreignKeyName       = explode('.', $model->$key()->getForeignKey())[1];
260
+								$val->$foreignKeyName = $model->id;
261
+								$val->save();
262
+								$ids[] = $val->id;
263
+								break;
264 264
 
265
-                            case 'BelongsToMany':
266
-                                $val->save();
267
-                                $ids[] = $val->id;
268
-                                break;
269
-                        }
270
-                    }
271
-                    switch (class_basename($model->$key())) 
272
-                    {
273
-                        case 'HasMany':
274
-                            $model->$key()->whereNotIn('id', $ids)->delete();
275
-                            break;
265
+							case 'BelongsToMany':
266
+								$val->save();
267
+								$ids[] = $val->id;
268
+								break;
269
+						}
270
+					}
271
+					switch (class_basename($model->$key())) 
272
+					{
273
+						case 'HasMany':
274
+							$model->$key()->whereNotIn('id', $ids)->delete();
275
+							break;
276 276
 
277
-                        case 'BelongsToMany':
278
-                            $model->$key()->detach();
279
-                            $model->$key()->attach($ids);
280
-                            break;
281
-                    }
282
-                }
283
-                else
284
-                {
285
-                    switch (class_basename($model->$key())) 
286
-                    {
287
-                        case 'BelongsTo':
288
-                            $value->save();
289
-                            $model->$key()->associate($value);
290
-                            $model->save();
291
-                            break;
292
-                    }
293
-                }
294
-            }
295
-            $saveLog ? $this->logs->saveLog(array_key_exists('id', $data) ? 'update' : 'create', class_basename($modelClass), $this->getModel(), $model->id, $model) : false;
296
-        });
277
+						case 'BelongsToMany':
278
+							$model->$key()->detach();
279
+							$model->$key()->attach($ids);
280
+							break;
281
+					}
282
+				}
283
+				else
284
+				{
285
+					switch (class_basename($model->$key())) 
286
+					{
287
+						case 'BelongsTo':
288
+							$value->save();
289
+							$model->$key()->associate($value);
290
+							$model->save();
291
+							break;
292
+					}
293
+				}
294
+			}
295
+			$saveLog ? $this->logs->saveLog(array_key_exists('id', $data) ? 'update' : 'create', class_basename($modelClass), $this->getModel(), $model->id, $model) : false;
296
+		});
297 297
         
298
-        $this->afterSave($model, $relations);
298
+		$this->afterSave($model, $relations);
299 299
 
300
-        return $this->find($model->id, $with);
301
-    }
300
+		return $this->find($model->id, $with);
301
+	}
302 302
 
303
-    /**
304
-     * Save the given models to the storage.
305
-     * 
306
-     * @param  array   $data
307
-     * @return object
308
-     */
309
-    public function saveMany(array $data)
310
-    {
311
-        $result = [];
312
-        \DB::transaction(function () use (&$result, $data) {
313
-            foreach ($data as $key => $value) 
314
-            {
315
-                $result[] = $this->save($value);
316
-            }
317
-        });
318
-        return $result;
319
-    }
303
+	/**
304
+	 * Save the given models to the storage.
305
+	 * 
306
+	 * @param  array   $data
307
+	 * @return object
308
+	 */
309
+	public function saveMany(array $data)
310
+	{
311
+		$result = [];
312
+		\DB::transaction(function () use (&$result, $data) {
313
+			foreach ($data as $key => $value) 
314
+			{
315
+				$result[] = $this->save($value);
316
+			}
317
+		});
318
+		return $result;
319
+	}
320 320
     
321
-    /**
322
-     * Update record in the storage based on the given
323
-     * condition.
324
-     * 
325
-     * @param  [type] $value condition value
326
-     * @param  array $data
327
-     * @param  string $attribute condition column name
328
-     * @return void
329
-     */
330
-    public function update($value, array $data, $attribute = 'id', $saveLog = true)
331
-    {
332
-        if ($attribute == 'id') 
333
-        {
334
-            $model = $this->model->lockForUpdate()->find($value);
335
-            $model ? $model->update($data) : 0;
336
-            $saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false;
337
-        }
338
-    	call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
339
-            $model->update($data);
340
-            $saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
341
-        });
342
-    }
321
+	/**
322
+	 * Update record in the storage based on the given
323
+	 * condition.
324
+	 * 
325
+	 * @param  [type] $value condition value
326
+	 * @param  array $data
327
+	 * @param  string $attribute condition column name
328
+	 * @return void
329
+	 */
330
+	public function update($value, array $data, $attribute = 'id', $saveLog = true)
331
+	{
332
+		if ($attribute == 'id') 
333
+		{
334
+			$model = $this->model->lockForUpdate()->find($value);
335
+			$model ? $model->update($data) : 0;
336
+			$saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false;
337
+		}
338
+		call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
339
+			$model->update($data);
340
+			$saveLog ? $this->logs->saveLog('update', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
341
+		});
342
+	}
343 343
     
344
-    /**
345
-     * Delete record from the storage based on the given
346
-     * condition.
347
-     * 
348
-     * @param  [type] $value condition value
349
-     * @param  string $attribute condition column name
350
-     * @return void
351
-     */
352
-    public function delete($value, $attribute = 'id', $saveLog = true)
353
-    {
354
-    	if ($attribute == 'id') 
355
-    	{
356
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
357
-                $model = $this->model->lockForUpdate()->find($value);
358
-                $model->delete();
359
-                $saveLog ? $this->logs->saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false;
360
-            });
361
-    	}
362
-        else
363
-        {
364
-            \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
365
-                call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
366
-                    $model->delete();
367
-                    $saveLog ? $this->logs->saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
368
-                });
369
-            });   
370
-        }
371
-    }
344
+	/**
345
+	 * Delete record from the storage based on the given
346
+	 * condition.
347
+	 * 
348
+	 * @param  [type] $value condition value
349
+	 * @param  string $attribute condition column name
350
+	 * @return void
351
+	 */
352
+	public function delete($value, $attribute = 'id', $saveLog = true)
353
+	{
354
+		if ($attribute == 'id') 
355
+		{
356
+			\DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
357
+				$model = $this->model->lockForUpdate()->find($value);
358
+				$model->delete();
359
+				$saveLog ? $this->logs->saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false;
360
+			});
361
+		}
362
+		else
363
+		{
364
+			\DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
365
+				call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model){
366
+					$model->delete();
367
+					$saveLog ? $this->logs->saveLog('delete', class_basename($this->model), $this->getModel(), $model->id, $model) : false;
368
+				});
369
+			});   
370
+		}
371
+	}
372 372
     
373
-    /**
374
-     * Fetch records from the storage based on the given
375
-     * id.
376
-     * 
377
-     * @param  integer $id
378
-     * @param  array   $relations
379
-     * @param  array   $columns
380
-     * @return object
381
-     */
382
-    public function find($id, $relations = [], $columns = array('*'))
383
-    {
384
-        return call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns);
385
-    }
373
+	/**
374
+	 * Fetch records from the storage based on the given
375
+	 * id.
376
+	 * 
377
+	 * @param  integer $id
378
+	 * @param  array   $relations
379
+	 * @param  array   $columns
380
+	 * @return object
381
+	 */
382
+	public function find($id, $relations = [], $columns = array('*'))
383
+	{
384
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns);
385
+	}
386 386
     
387
-    /**
388
-     * Fetch records from the storage based on the given
389
-     * condition.
390
-     * 
391
-     * @param  array   $conditions array of conditions
392
-     * @param  array   $relations
393
-     * @param  string  $sortBy
394
-     * @param  boolean $desc
395
-     * @param  array   $columns
396
-     * @return collection
397
-     */
398
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
399
-    {
400
-        $conditions = $this->constructConditions($conditions);
401
-        $sort       = $desc ? 'desc' : 'asc';
402
-        return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
403
-    }
387
+	/**
388
+	 * Fetch records from the storage based on the given
389
+	 * condition.
390
+	 * 
391
+	 * @param  array   $conditions array of conditions
392
+	 * @param  array   $relations
393
+	 * @param  string  $sortBy
394
+	 * @param  boolean $desc
395
+	 * @param  array   $columns
396
+	 * @return collection
397
+	 */
398
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = array('*'))
399
+	{
400
+		$conditions = $this->constructConditions($conditions);
401
+		$sort       = $desc ? 'desc' : 'asc';
402
+		return call_user_func_array("{$this->getModel()}::with",  array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
403
+	}
404 404
 
405
-    /**
406
-     * Fetch the first record from the storage based on the given
407
-     * condition.
408
-     *
409
-     * @param  array   $conditions array of conditions
410
-     * @param  array   $relations
411
-     * @param  array   $colunmns
412
-     * @return object
413
-     */
414
-    public function first($conditions, $relations = [], $columns = array('*'))
415
-    {
416
-        $conditions = $this->constructConditions($conditions);
417
-        return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);  
418
-    }
405
+	/**
406
+	 * Fetch the first record from the storage based on the given
407
+	 * condition.
408
+	 *
409
+	 * @param  array   $conditions array of conditions
410
+	 * @param  array   $relations
411
+	 * @param  array   $colunmns
412
+	 * @return object
413
+	 */
414
+	public function first($conditions, $relations = [], $columns = array('*'))
415
+	{
416
+		$conditions = $this->constructConditions($conditions);
417
+		return call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);  
418
+	}
419 419
 
420
-    /**
421
-     * Build the conditions recursively for the retrieving methods.
422
-     * @param  array $conditions
423
-     * @return array
424
-     */
425
-    protected function constructConditions($conditions)
426
-    {   
427
-        $conditionString = '';
428
-        $conditionValues = [];
429
-        foreach ($conditions as $key => $value) 
430
-        {
431
-            if ($key == 'and') 
432
-            {
433
-                $conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} ';
434
-                $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
435
-            }
436
-            else if ($key == 'or')
437
-            {
438
-                $conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} ';
439
-                $conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
440
-            }
441
-            else
442
-            {
443
-                $conditionString  .= $key . '=? {op} ';
444
-                $conditionValues[] = $value;
445
-            }
446
-        }
447
-        $conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
448
-        return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
449
-    }
420
+	/**
421
+	 * Build the conditions recursively for the retrieving methods.
422
+	 * @param  array $conditions
423
+	 * @return array
424
+	 */
425
+	protected function constructConditions($conditions)
426
+	{   
427
+		$conditionString = '';
428
+		$conditionValues = [];
429
+		foreach ($conditions as $key => $value) 
430
+		{
431
+			if ($key == 'and') 
432
+			{
433
+				$conditionString  .= str_replace('{op}', 'and', $this->constructConditions($value)['conditionString']) . ' {op} ';
434
+				$conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
435
+			}
436
+			else if ($key == 'or')
437
+			{
438
+				$conditionString  .= str_replace('{op}', 'or', $this->constructConditions($value)['conditionString']) . ' {op} ';
439
+				$conditionValues   = array_merge($conditionValues, $this->constructConditions($value)['conditionValues']);
440
+			}
441
+			else
442
+			{
443
+				$conditionString  .= $key . '=? {op} ';
444
+				$conditionValues[] = $value;
445
+			}
446
+		}
447
+		$conditionString = '(' . rtrim($conditionString, '{op} ') . ')';
448
+		return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
449
+	}
450 450
 
451
-    /**
452
-     * Abstract method that is called in after
453
-     * the save method finish.
454
-     * 
455
-     * @param  object  $model
456
-     * @param  array   $relations
457
-     * @return void
458
-     */
459
-    protected function afterSave($model, $relations)
460
-    {
461
-        return false;
462
-    }
451
+	/**
452
+	 * Abstract method that is called in after
453
+	 * the save method finish.
454
+	 * 
455
+	 * @param  object  $model
456
+	 * @param  array   $relations
457
+	 * @return void
458
+	 */
459
+	protected function afterSave($model, $relations)
460
+	{
461
+		return false;
462
+	}
463 463
 
464
-    /**
465
-     * Abstract method that return the necessary 
466
-     * information (full model namespace)
467
-     * needed to preform the previous actions.
468
-     * 
469
-     * @return string
470
-     */
471
-    abstract protected function getModel();
464
+	/**
465
+	 * Abstract method that return the necessary 
466
+	 * information (full model namespace)
467
+	 * needed to preform the previous actions.
468
+	 * 
469
+	 * @return string
470
+	 */
471
+	abstract protected function getModel();
472 472
 }
473 473
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/Core/CoreConfig.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@  discard block
 block discarded – undo
2 2
 
3 3
 class CoreConfig
4 4
 {
5
-    public function getConfig()
6
-    {
7
-    	$customSettings = [];
8
-    	Settings::get(['key', 'value'])->each(function ($setting) use (&$customSettings){
9
-    		$customSettings[$setting['key']] = $setting['value'];
10
-    	});
5
+	public function getConfig()
6
+	{
7
+		$customSettings = [];
8
+		Settings::get(['key', 'value'])->each(function ($setting) use (&$customSettings){
9
+			$customSettings[$setting['key']] = $setting['value'];
10
+		});
11 11
 
12
-        return array_merge($customSettings, [
12
+		return array_merge($customSettings, [
13 13
 			/**
14 14
 			 * Specify what relations should be used for every model.
15 15
 			 */
@@ -56,5 +56,5 @@  discard block
 block discarded – undo
56 56
 				],
57 57
 			]
58 58
 		]);
59
-    }
59
+	}
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/Core/Log.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 
3 3
 class Log
4 4
 {
5
-    public function saveLog($action, $item_name, $item_type, $item_id, $model = false)
6
-    {
7
-    	if (\Core::logs() && $item_name !== 'Log')
8
-    	{
9
-            $item_name = $item_name;
10
-    		\Core::logs()->save([
11
-	    		'action'      => $action,
12
-	    		'item_name'   => $item_name,
13
-	    		'item_type'   => $item_type,
14
-	    		'item_id'     => $item_id,
15
-	    		'user_id'     => \Auth::user()->id,
16
-	    		], false, false);
17
-    	}
18
-    }
5
+	public function saveLog($action, $item_name, $item_type, $item_id, $model = false)
6
+	{
7
+		if (\Core::logs() && $item_name !== 'Log')
8
+		{
9
+			$item_name = $item_name;
10
+			\Core::logs()->save([
11
+				'action'      => $action,
12
+				'item_name'   => $item_name,
13
+				'item_type'   => $item_type,
14
+				'item_id'     => $item_id,
15
+				'user_id'     => \Auth::user()->id,
16
+				], false, false);
17
+		}
18
+	}
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/Core/Interfaces/RepositoryInterface.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -3,127 +3,127 @@
 block discarded – undo
3 3
 interface RepositoryInterface
4 4
 {
5 5
 	/**
6
-     * Fetch all records with relations from the storage.
7
-     * 
8
-     * @param  array  $relations
9
-     * @param  array   $sortBy
10
-     * @param  array   $desc
11
-     * @param  array  $columns
12
-     * @return collection
13
-     */
6
+	 * Fetch all records with relations from the storage.
7
+	 * 
8
+	 * @param  array  $relations
9
+	 * @param  array   $sortBy
10
+	 * @param  array   $desc
11
+	 * @param  array  $columns
12
+	 * @return collection
13
+	 */
14 14
 	public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
15 15
  	
16
-    /**
17
-     * Fetch all records with relations from storage in pages 
18
-     * that matche the given query.
19
-     * 
20
-     * @param  string  $query
21
-     * @param  integer $perPage
22
-     * @param  array   $relations
23
-     * @param  array   $sortBy
24
-     * @param  array   $desc
25
-     * @param  array   $columns
26
-     * @return collection
27
-     */
28
-    public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
16
+	/**
17
+	 * Fetch all records with relations from storage in pages 
18
+	 * that matche the given query.
19
+	 * 
20
+	 * @param  string  $query
21
+	 * @param  integer $perPage
22
+	 * @param  array   $relations
23
+	 * @param  array   $sortBy
24
+	 * @param  array   $desc
25
+	 * @param  array   $columns
26
+	 * @return collection
27
+	 */
28
+	public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
29 29
 
30 30
 	/**
31
-     * Fetch all records with relations from storage in pages.
32
-     * 
33
-     * @param  integer $perPage
34
-     * @param  array   $relations
35
-     * @param  array   $sortBy
36
-     * @param  array   $desc
37
-     * @param  array   $columns
38
-     * @return collection
39
-     */
40
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
31
+	 * Fetch all records with relations from storage in pages.
32
+	 * 
33
+	 * @param  integer $perPage
34
+	 * @param  array   $relations
35
+	 * @param  array   $sortBy
36
+	 * @param  array   $desc
37
+	 * @param  array   $columns
38
+	 * @return collection
39
+	 */
40
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
41 41
  	
42 42
 	/**
43
-     * Fetch all records with relations based on
44
-     * the given condition from storage in pages.
45
-     * 
46
-     * @param  array   $conditions array of conditions
47
-     * @param  integer $perPage
48
-     * @param  array   $relations
49
-     * @param  array   $sortBy
50
-     * @param  array   $desc
51
-     * @param  array   $columns
52
-     * @return collection
53
-     */
54
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
43
+	 * Fetch all records with relations based on
44
+	 * the given condition from storage in pages.
45
+	 * 
46
+	 * @param  array   $conditions array of conditions
47
+	 * @param  integer $perPage
48
+	 * @param  array   $relations
49
+	 * @param  array   $sortBy
50
+	 * @param  array   $desc
51
+	 * @param  array   $columns
52
+	 * @return collection
53
+	 */
54
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
55 55
 
56
-     /**
57
-     * Save the given model/models to the storage.
58
-     * 
59
-     * @param  array   $data
60
-     * @param  boolean $saveLog
61
-     * @return object
62
-     */
63
-    public function save(array $data, $saveLog = true);
56
+	 /**
57
+	  * Save the given model/models to the storage.
58
+	  * 
59
+	  * @param  array   $data
60
+	  * @param  boolean $saveLog
61
+	  * @return object
62
+	  */
63
+	public function save(array $data, $saveLog = true);
64 64
  	
65
-    /**
66
-     * Insert multiple records to the storage.
67
-     * 
68
-     * @param  array   $data
69
-     * @return object
70
-     */
71
-    public function saveMany(array $data);
65
+	/**
66
+	 * Insert multiple records to the storage.
67
+	 * 
68
+	 * @param  array   $data
69
+	 * @return object
70
+	 */
71
+	public function saveMany(array $data);
72 72
 
73 73
 	/**
74
-     * Update record in the storage based on the given
75
-     * condition.
76
-     * 
77
-     * @param  [type] $value condition value
78
-     * @param  array $data
79
-     * @param  string $attribute condition column name
80
-     * @return integer affected rows
81
-     */
82
-    public function update($value, array $data, $attribute = 'id');
74
+	 * Update record in the storage based on the given
75
+	 * condition.
76
+	 * 
77
+	 * @param  [type] $value condition value
78
+	 * @param  array $data
79
+	 * @param  string $attribute condition column name
80
+	 * @return integer affected rows
81
+	 */
82
+	public function update($value, array $data, $attribute = 'id');
83 83
  	
84 84
 	/**
85
-     * Delete record from the storage based on the given
86
-     * condition.
87
-     * 
88
-     * @param  [type] $value condition value
89
-     * @param  string $attribute condition column name
90
-     * @return integer affected rows
91
-     */
92
-    public function delete($value, $attribute = 'id');
85
+	 * Delete record from the storage based on the given
86
+	 * condition.
87
+	 * 
88
+	 * @param  [type] $value condition value
89
+	 * @param  string $attribute condition column name
90
+	 * @return integer affected rows
91
+	 */
92
+	public function delete($value, $attribute = 'id');
93 93
  	
94 94
 	/**
95
-     * Fetch records from the storage based on the given
96
-     * id.
97
-     * 
98
-     * @param  integer $id
99
-     * @param  array   $relations
100
-     * @param  array   $columns
101
-     * @return object
102
-     */
103
-    public function find($id, $relations = [], $columns = array('*'));
95
+	 * Fetch records from the storage based on the given
96
+	 * id.
97
+	 * 
98
+	 * @param  integer $id
99
+	 * @param  array   $relations
100
+	 * @param  array   $columns
101
+	 * @return object
102
+	 */
103
+	public function find($id, $relations = [], $columns = array('*'));
104 104
  	
105 105
 	/**
106
-     * Fetch records from the storage based on the given
107
-     * condition.
108
-     * 
109
-     * @param  array   $conditions array of conditions
110
-     * @param  array   $relations
111
-     * @param  array   $sortBy
112
-     * @param  array   $desc
113
-     * @param  array   $columns
114
-     * @return collection
115
-     */
116
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
106
+	 * Fetch records from the storage based on the given
107
+	 * condition.
108
+	 * 
109
+	 * @param  array   $conditions array of conditions
110
+	 * @param  array   $relations
111
+	 * @param  array   $sortBy
112
+	 * @param  array   $desc
113
+	 * @param  array   $columns
114
+	 * @return collection
115
+	 */
116
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*'));
117 117
 
118
-    /**
119
-     * Fetch the first record fro the storage based on the given
120
-     * condition.
121
-     * 
122
-     * @param  array   $conditions array of conditions
123
-     * @param  [type]  $value condition value
124
-     * @param  array   $relations
125
-     * @param  array   $columns
126
-     * @return object
127
-     */
128
-    public function first($conditions, $relations = [], $columns = array('*'));
118
+	/**
119
+	 * Fetch the first record fro the storage based on the given
120
+	 * condition.
121
+	 * 
122
+	 * @param  array   $conditions array of conditions
123
+	 * @param  [type]  $value condition value
124
+	 * @param  array   $relations
125
+	 * @param  array   $columns
126
+	 * @return object
127
+	 */
128
+	public function first($conditions, $relations = [], $columns = array('*'));
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.