Completed
Push — master ( bfbb50...8023d3 )
by Sherif
09:55
created
src/Modules/PushNotificationDevices/PushNotificationDevice.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,32 +10,32 @@
 block discarded – undo
10 10
 class PushNotificationDevice extends Model
11 11
 {
12 12
 
13
-    use SoftDeletes;
14
-    protected $table    = 'push_notification_devices';
15
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
-    protected $hidden   = ['deleted_at', 'access_token'];
17
-    protected $guarded  = ['id'];
18
-    protected $fillable = ['device_token', 'user_id', 'access_token'];
13
+	use SoftDeletes;
14
+	protected $table    = 'push_notification_devices';
15
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
+	protected $hidden   = ['deleted_at', 'access_token'];
17
+	protected $guarded  = ['id'];
18
+	protected $fillable = ['device_token', 'user_id', 'access_token'];
19 19
     
20
-    public function user()
21
-    {
22
-        return $this->belongsTo(AclUser::class);
23
-    }
20
+	public function user()
21
+	{
22
+		return $this->belongsTo(AclUser::class);
23
+	}
24 24
 
25
-    /**
26
-     * Encrypt the access_token attribute before
27
-     * saving it in the storage.
28
-     *
29
-     * @param string $value
30
-     */
31
-    public function setLoginTokenAttribute($value)
32
-    {
33
-        $this->attributes['access_token'] = encrypt($value);
34
-    }
25
+	/**
26
+	 * Encrypt the access_token attribute before
27
+	 * saving it in the storage.
28
+	 *
29
+	 * @param string $value
30
+	 */
31
+	public function setLoginTokenAttribute($value)
32
+	{
33
+		$this->attributes['access_token'] = encrypt($value);
34
+	}
35 35
 
36
-    public static function boot()
37
-    {
38
-        parent::boot();
39
-        PushNotificationDevice::observe(PushNotificationDeviceObserver::class);
40
-    }
36
+	public static function boot()
37
+	{
38
+		parent::boot();
39
+		PushNotificationDevice::observe(PushNotificationDeviceObserver::class);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Database/Migrations/2018_08_08_100000_create_telescope_entries_table.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -6,82 +6,82 @@
 block discarded – undo
6 6
 
7 7
 class CreateTelescopeEntriesTable extends Migration
8 8
 {
9
-    /**
10
-     * The database schema.
11
-     *
12
-     * @var \Illuminate\Database\Schema\Builder
13
-     */
14
-    protected $schema;
9
+	/**
10
+	 * The database schema.
11
+	 *
12
+	 * @var \Illuminate\Database\Schema\Builder
13
+	 */
14
+	protected $schema;
15 15
 
16
-    /**
17
-     * Create a new migration instance.
18
-     *
19
-     * @return void
20
-     */
21
-    public function __construct()
22
-    {
23
-        $this->schema = Schema::connection($this->getConnection());
24
-    }
16
+	/**
17
+	 * Create a new migration instance.
18
+	 *
19
+	 * @return void
20
+	 */
21
+	public function __construct()
22
+	{
23
+		$this->schema = Schema::connection($this->getConnection());
24
+	}
25 25
 
26
-    /**
27
-     * Get the migration connection name.
28
-     *
29
-     * @return string|null
30
-     */
31
-    public function getConnection()
32
-    {
33
-        return config('telescope.storage.database.connection');
34
-    }
26
+	/**
27
+	 * Get the migration connection name.
28
+	 *
29
+	 * @return string|null
30
+	 */
31
+	public function getConnection()
32
+	{
33
+		return config('telescope.storage.database.connection');
34
+	}
35 35
 
36
-    /**
37
-     * Run the migrations.
38
-     *
39
-     * @return void
40
-     */
41
-    public function up()
42
-    {
43
-        $this->schema->create('telescope_entries', function (Blueprint $table) {
44
-            $table->bigIncrements('sequence');
45
-            $table->uuid('uuid');
46
-            $table->uuid('batch_id');
47
-            $table->string('family_hash')->nullable()->index();
48
-            $table->boolean('should_display_on_index')->default(true);
49
-            $table->string('type', 20);
50
-            $table->longText('content');
51
-            $table->dateTime('created_at')->nullable();
36
+	/**
37
+	 * Run the migrations.
38
+	 *
39
+	 * @return void
40
+	 */
41
+	public function up()
42
+	{
43
+		$this->schema->create('telescope_entries', function (Blueprint $table) {
44
+			$table->bigIncrements('sequence');
45
+			$table->uuid('uuid');
46
+			$table->uuid('batch_id');
47
+			$table->string('family_hash')->nullable()->index();
48
+			$table->boolean('should_display_on_index')->default(true);
49
+			$table->string('type', 20);
50
+			$table->longText('content');
51
+			$table->dateTime('created_at')->nullable();
52 52
 
53
-            $table->unique('uuid');
54
-            $table->index('batch_id');
55
-            $table->index(['type', 'should_display_on_index']);
56
-        });
53
+			$table->unique('uuid');
54
+			$table->index('batch_id');
55
+			$table->index(['type', 'should_display_on_index']);
56
+		});
57 57
 
58
-        $this->schema->create('telescope_entries_tags', function (Blueprint $table) {
59
-            $table->uuid('entry_uuid');
60
-            $table->string('tag');
58
+		$this->schema->create('telescope_entries_tags', function (Blueprint $table) {
59
+			$table->uuid('entry_uuid');
60
+			$table->string('tag');
61 61
 
62
-            $table->index(['entry_uuid', 'tag']);
63
-            $table->index('tag');
62
+			$table->index(['entry_uuid', 'tag']);
63
+			$table->index('tag');
64 64
 
65
-            $table->foreign('entry_uuid')
66
-                  ->references('uuid')
67
-                  ->on('telescope_entries')
68
-                  ->onDelete('cascade');
69
-        });
65
+			$table->foreign('entry_uuid')
66
+				  ->references('uuid')
67
+				  ->on('telescope_entries')
68
+				  ->onDelete('cascade');
69
+		});
70 70
 
71
-        $this->schema->create('telescope_monitoring', function (Blueprint $table) {
72
-            $table->string('tag');
73
-        });
74
-    }
71
+		$this->schema->create('telescope_monitoring', function (Blueprint $table) {
72
+			$table->string('tag');
73
+		});
74
+	}
75 75
 
76
-    /**
77
-     * Reverse the migrations.
78
-     *
79
-     * @return void
80
-     */
81
-    public function down()
82
-    {
83
-        $this->schema->dropIfExists('telescope_entries_tags');
84
-        $this->schema->dropIfExists('telescope_entries');
85
-        $this->schema->dropIfExists('telescope_monitoring');
86
-    }
76
+	/**
77
+	 * Reverse the migrations.
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public function down()
82
+	{
83
+		$this->schema->dropIfExists('telescope_entries_tags');
84
+		$this->schema->dropIfExists('telescope_entries');
85
+		$this->schema->dropIfExists('telescope_monitoring');
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function up()
42 42
     {
43
-        $this->schema->create('telescope_entries', function (Blueprint $table) {
43
+        $this->schema->create('telescope_entries', function(Blueprint $table) {
44 44
             $table->bigIncrements('sequence');
45 45
             $table->uuid('uuid');
46 46
             $table->uuid('batch_id');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             $table->index(['type', 'should_display_on_index']);
56 56
         });
57 57
 
58
-        $this->schema->create('telescope_entries_tags', function (Blueprint $table) {
58
+        $this->schema->create('telescope_entries_tags', function(Blueprint $table) {
59 59
             $table->uuid('entry_uuid');
60 60
             $table->string('tag');
61 61
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                   ->onDelete('cascade');
69 69
         });
70 70
 
71
-        $this->schema->create('telescope_monitoring', function (Blueprint $table) {
71
+        $this->schema->create('telescope_monitoring', function(Blueprint $table) {
72 72
             $table->string('tag');
73 73
         });
74 74
     }
Please login to merge, or discard this patch.
src/Modules/Core/Setting.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@
 block discarded – undo
9 9
 class Setting extends Model
10 10
 {
11 11
 
12
-    use SoftDeletes;
13
-    protected $table    = 'settings';
14
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
15
-    protected $hidden   = ['deleted_at'];
16
-    protected $guarded  = ['id', 'key'];
17
-    protected $fillable = ['name', 'value'];
12
+	use SoftDeletes;
13
+	protected $table    = 'settings';
14
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
15
+	protected $hidden   = ['deleted_at'];
16
+	protected $guarded  = ['id', 'key'];
17
+	protected $fillable = ['name', 'value'];
18 18
     
19
-    public function newCollection(array $models = [])
20
-    {
21
-        return parent::newCollection($models)->keyBy('key');
22
-    }
19
+	public function newCollection(array $models = [])
20
+	{
21
+		return parent::newCollection($models)->keyBy('key');
22
+	}
23 23
 
24
-    public static function boot()
25
-    {
26
-        parent::boot();
27
-        Setting::observe(SettingsObserver::class);
28
-    }
24
+	public static function boot()
25
+	{
26
+		parent::boot();
27
+		Setting::observe(SettingsObserver::class);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
src/Modules/Core/Errors/Errors.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@
 block discarded – undo
6 6
 
7 7
 class Errors implements BaseFactoryInterface
8 8
 {
9
-    /**
10
-     * Construct the repository class name based on
11
-     * the method name called, search in the
12
-     * given namespaces for the class and
13
-     * return an instance.
14
-     *
15
-     * @param  string $name the called method name
16
-     * @param  array  $arguments the method arguments
17
-     * @return object
18
-     */
19
-    public function __call($name, $arguments)
20
-    {
21
-        foreach (\Module::all() as $module) {
22
-            $nameSpace = 'App\\Modules\\' . $module['basename'];
23
-            $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors';
9
+	/**
10
+	 * Construct the repository class name based on
11
+	 * the method name called, search in the
12
+	 * given namespaces for the class and
13
+	 * return an instance.
14
+	 *
15
+	 * @param  string $name the called method name
16
+	 * @param  array  $arguments the method arguments
17
+	 * @return object
18
+	 */
19
+	public function __call($name, $arguments)
20
+	{
21
+		foreach (\Module::all() as $module) {
22
+			$nameSpace = 'App\\Modules\\' . $module['basename'];
23
+			$class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors';
24 24
 
25
-            if (class_exists($class)) {
26
-                $class = \App::make($class);
27
-                if (method_exists($class, $name)) {
28
-                    return call_user_func_array([$class, $name], $arguments);
29
-                }
30
-            }
31
-        }
32
-    }
25
+			if (class_exists($class)) {
26
+				$class = \App::make($class);
27
+				if (method_exists($class, $name)) {
28
+					return call_user_func_array([$class, $name], $arguments);
29
+				}
30
+			}
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseRepository.php 2 patches
Indentation   +534 added lines, -534 removed lines patch added patch discarded remove patch
@@ -8,548 +8,548 @@
 block discarded – undo
8 8
 
9 9
 abstract class BaseRepository implements BaseRepositoryInterface
10 10
 {
11
-    /**
12
-     * @var object
13
-     */
14
-    public $model;
11
+	/**
12
+	 * @var object
13
+	 */
14
+	public $model;
15 15
     
16
-    /**
17
-     * Init new object.
18
-     *
19
-     * @var mixed model
20
-     * @return  void
21
-     */
22
-    public function __construct($model)
23
-    {
24
-        $this->model  = $model;
25
-    }
26
-
27
-    /**
28
-     * Fetch all records with relations from the storage.
29
-     *
30
-     * @param  array   $relations
31
-     * @param  string  $sortBy
32
-     * @param  boolean $desc
33
-     * @param  array   $columns
34
-     * @return collection
35
-     */
36
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
-    {
38
-        $sort = $desc ? 'desc' : 'asc';
39
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
-    }
16
+	/**
17
+	 * Init new object.
18
+	 *
19
+	 * @var mixed model
20
+	 * @return  void
21
+	 */
22
+	public function __construct($model)
23
+	{
24
+		$this->model  = $model;
25
+	}
26
+
27
+	/**
28
+	 * Fetch all records with relations from the storage.
29
+	 *
30
+	 * @param  array   $relations
31
+	 * @param  string  $sortBy
32
+	 * @param  boolean $desc
33
+	 * @param  array   $columns
34
+	 * @return collection
35
+	 */
36
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
+	{
38
+		$sort = $desc ? 'desc' : 'asc';
39
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
+	}
41 41
     
42
-    /**
43
-     * Fetch all records with relations from storage in pages.
44
-     *
45
-     * @param  integer $perPage
46
-     * @param  array   $relations
47
-     * @param  string  $sortBy
48
-     * @param  boolean $desc
49
-     * @param  array   $columns
50
-     * @return collection
51
-     */
52
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
-    {
54
-        $sort = $desc ? 'desc' : 'asc';
55
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
-    }
57
-
58
-    /**
59
-     * Fetch all records with relations based on
60
-     * the given condition from storage in pages.
61
-     *
62
-     * @param  array   $conditions array of conditions
63
-     * @param  integer $perPage
64
-     * @param  array   $relations
65
-     * @param  string  $sortBy
66
-     * @param  boolean $desc
67
-     * @param  array   $columns
68
-     * @return collection
69
-     */
70
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
-    {
72
-        $conditions = $this->constructConditions($conditions, $this->model);
73
-        $sort       = $desc ? 'desc' : 'asc';
74
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
-    }
42
+	/**
43
+	 * Fetch all records with relations from storage in pages.
44
+	 *
45
+	 * @param  integer $perPage
46
+	 * @param  array   $relations
47
+	 * @param  string  $sortBy
48
+	 * @param  boolean $desc
49
+	 * @param  array   $columns
50
+	 * @return collection
51
+	 */
52
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
+	{
54
+		$sort = $desc ? 'desc' : 'asc';
55
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
+	}
57
+
58
+	/**
59
+	 * Fetch all records with relations based on
60
+	 * the given condition from storage in pages.
61
+	 *
62
+	 * @param  array   $conditions array of conditions
63
+	 * @param  integer $perPage
64
+	 * @param  array   $relations
65
+	 * @param  string  $sortBy
66
+	 * @param  boolean $desc
67
+	 * @param  array   $columns
68
+	 * @return collection
69
+	 */
70
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
+	{
72
+		$conditions = $this->constructConditions($conditions, $this->model);
73
+		$sort       = $desc ? 'desc' : 'asc';
74
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
+	}
76 76
     
77
-    /**
78
-     * Save the given model to the storage.
79
-     *
80
-     * @param  array $data
81
-     * @return mixed
82
-     */
83
-    public function save(array $data)
84
-    {
85
-        \Session::put('locale', 'all');
86
-        $model      = false;
87
-        $relations  = [];
88
-
89
-        \DB::transaction(function () use (&$model, &$relations, $data) {
77
+	/**
78
+	 * Save the given model to the storage.
79
+	 *
80
+	 * @param  array $data
81
+	 * @return mixed
82
+	 */
83
+	public function save(array $data)
84
+	{
85
+		\Session::put('locale', 'all');
86
+		$model      = false;
87
+		$relations  = [];
88
+
89
+		\DB::transaction(function () use (&$model, &$relations, $data) {
90 90
             
91
-            $model     = $this->prepareModel($data);
92
-            $relations = $this->prepareRelations($data, $model);
93
-            $model     = $this->saveModel($model, $relations);
94
-        });
91
+			$model     = $this->prepareModel($data);
92
+			$relations = $this->prepareRelations($data, $model);
93
+			$model     = $this->saveModel($model, $relations);
94
+		});
95 95
         
96
-        if (count($relations)) {
97
-            $model->load(...array_keys($relations));
98
-        }
99
-
100
-        return $model;
101
-    }
102
-
103
-    /**
104
-     * Delete record from the storage based on the given
105
-     * condition.
106
-     *
107
-     * @param  var $value condition value
108
-     * @param  string $attribute condition column name
109
-     * @return void
110
-     */
111
-    public function delete($value, $attribute = 'id')
112
-    {
113
-        \DB::transaction(function () use ($value, $attribute) {
114
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
115
-                $model->delete();
116
-            });
117
-        });
118
-    }
96
+		if (count($relations)) {
97
+			$model->load(...array_keys($relations));
98
+		}
99
+
100
+		return $model;
101
+	}
102
+
103
+	/**
104
+	 * Delete record from the storage based on the given
105
+	 * condition.
106
+	 *
107
+	 * @param  var $value condition value
108
+	 * @param  string $attribute condition column name
109
+	 * @return void
110
+	 */
111
+	public function delete($value, $attribute = 'id')
112
+	{
113
+		\DB::transaction(function () use ($value, $attribute) {
114
+			$this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
115
+				$model->delete();
116
+			});
117
+		});
118
+	}
119 119
     
120
-    /**
121
-     * Fetch records from the storage based on the given
122
-     * id.
123
-     *
124
-     * @param  integer $id
125
-     * @param  string[]   $relations
126
-     * @param  array   $columns
127
-     * @return object
128
-     */
129
-    public function find($id, $relations = [], $columns = ['*'])
130
-    {
131
-        return $this->model->with($relations)->find($id, $columns);
132
-    }
120
+	/**
121
+	 * Fetch records from the storage based on the given
122
+	 * id.
123
+	 *
124
+	 * @param  integer $id
125
+	 * @param  string[]   $relations
126
+	 * @param  array   $columns
127
+	 * @return object
128
+	 */
129
+	public function find($id, $relations = [], $columns = ['*'])
130
+	{
131
+		return $this->model->with($relations)->find($id, $columns);
132
+	}
133 133
     
134
-    /**
135
-     * Fetch records from the storage based on the given
136
-     * condition.
137
-     *
138
-     * @param  array   $conditions array of conditions
139
-     * @param  array   $relations
140
-     * @param  string  $sortBy
141
-     * @param  boolean $desc
142
-     * @param  array   $columns
143
-     * @return collection
144
-     */
145
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
146
-    {
147
-        $conditions = $this->constructConditions($conditions, $this->model);
148
-        $sort       = $desc ? 'desc' : 'asc';
149
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
150
-    }
151
-
152
-    /**
153
-     * Fetch the first record from the storage based on the given
154
-     * condition.
155
-     *
156
-     * @param  array   $conditions array of conditions
157
-     * @param  array   $relations
158
-     * @param  array   $columns
159
-     * @return object
160
-     */
161
-    public function first($conditions, $relations = [], $columns = ['*'])
162
-    {
163
-        $conditions = $this->constructConditions($conditions, $this->model);
164
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
165
-    }
166
-
167
-    /**
168
-     * Return the deleted models in pages based on the given conditions.
169
-     *
170
-     * @param  array   $conditions array of conditions
171
-     * @param  integer $perPage
172
-     * @param  string  $sortBy
173
-     * @param  boolean $desc
174
-     * @param  array   $columns
175
-     * @return collection
176
-     */
177
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
178
-    {
179
-        unset($conditions['page']);
180
-        unset($conditions['perPage']);
181
-        unset($conditions['sortBy']);
182
-        unset($conditions['sort']);
183
-        $conditions = $this->constructConditions($conditions, $this->model);
184
-        $sort       = $desc ? 'desc' : 'asc';
185
-        $model      = $this->model->onlyTrashed();
186
-
187
-        if (count($conditions['conditionValues'])) {
188
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
189
-        }
190
-
191
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
192
-    }
193
-
194
-    /**
195
-     * Restore the deleted model.
196
-     *
197
-     * @param  integer $id
198
-     * @return void
199
-     */
200
-    public function restore($id)
201
-    {
202
-        $model = $this->model->onlyTrashed()->find($id);
203
-
204
-        if (! $model) {
205
-            \Errors::notFound(class_basename($this->model).' with id : '.$id);
206
-        }
207
-
208
-        $model->restore();
209
-    }
210
-
211
-    /**
212
-     * Fill the model with the given data.
213
-     *
214
-     * @param   array  $data
215
-     *
216
-     * @return  object
217
-     */
218
-    public function prepareModel($data)
219
-    {
220
-        $modelClass = $this->model;
221
-
222
-        /**
223
-         * If the id is present in the data then select the model for updating,
224
-         * else create new model.
225
-         * @var array
226
-         */
227
-        $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
228
-        if (! $model) {
229
-            \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
230
-        }
231
-
232
-        /**
233
-         * Construct the model object with the given data,
234
-         * and if there is a relation add it to relations array,
235
-         * then save the model.
236
-         */
237
-        foreach ($data as $key => $value) {
238
-            if (array_search($key, $model->getFillable(), true) !== false) {
239
-                /**
240
-                 * If the attribute isn't a relation and prevent attributes not in the fillable.
241
-                 */
242
-                $model->$key = $value;
243
-            }
244
-        }
245
-
246
-        return $model;
247
-    }
134
+	/**
135
+	 * Fetch records from the storage based on the given
136
+	 * condition.
137
+	 *
138
+	 * @param  array   $conditions array of conditions
139
+	 * @param  array   $relations
140
+	 * @param  string  $sortBy
141
+	 * @param  boolean $desc
142
+	 * @param  array   $columns
143
+	 * @return collection
144
+	 */
145
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
146
+	{
147
+		$conditions = $this->constructConditions($conditions, $this->model);
148
+		$sort       = $desc ? 'desc' : 'asc';
149
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
150
+	}
151
+
152
+	/**
153
+	 * Fetch the first record from the storage based on the given
154
+	 * condition.
155
+	 *
156
+	 * @param  array   $conditions array of conditions
157
+	 * @param  array   $relations
158
+	 * @param  array   $columns
159
+	 * @return object
160
+	 */
161
+	public function first($conditions, $relations = [], $columns = ['*'])
162
+	{
163
+		$conditions = $this->constructConditions($conditions, $this->model);
164
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
165
+	}
166
+
167
+	/**
168
+	 * Return the deleted models in pages based on the given conditions.
169
+	 *
170
+	 * @param  array   $conditions array of conditions
171
+	 * @param  integer $perPage
172
+	 * @param  string  $sortBy
173
+	 * @param  boolean $desc
174
+	 * @param  array   $columns
175
+	 * @return collection
176
+	 */
177
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
178
+	{
179
+		unset($conditions['page']);
180
+		unset($conditions['perPage']);
181
+		unset($conditions['sortBy']);
182
+		unset($conditions['sort']);
183
+		$conditions = $this->constructConditions($conditions, $this->model);
184
+		$sort       = $desc ? 'desc' : 'asc';
185
+		$model      = $this->model->onlyTrashed();
186
+
187
+		if (count($conditions['conditionValues'])) {
188
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
189
+		}
190
+
191
+		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
192
+	}
193
+
194
+	/**
195
+	 * Restore the deleted model.
196
+	 *
197
+	 * @param  integer $id
198
+	 * @return void
199
+	 */
200
+	public function restore($id)
201
+	{
202
+		$model = $this->model->onlyTrashed()->find($id);
203
+
204
+		if (! $model) {
205
+			\Errors::notFound(class_basename($this->model).' with id : '.$id);
206
+		}
207
+
208
+		$model->restore();
209
+	}
210
+
211
+	/**
212
+	 * Fill the model with the given data.
213
+	 *
214
+	 * @param   array  $data
215
+	 *
216
+	 * @return  object
217
+	 */
218
+	public function prepareModel($data)
219
+	{
220
+		$modelClass = $this->model;
221
+
222
+		/**
223
+		 * If the id is present in the data then select the model for updating,
224
+		 * else create new model.
225
+		 * @var array
226
+		 */
227
+		$model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
228
+		if (! $model) {
229
+			\Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
230
+		}
231
+
232
+		/**
233
+		 * Construct the model object with the given data,
234
+		 * and if there is a relation add it to relations array,
235
+		 * then save the model.
236
+		 */
237
+		foreach ($data as $key => $value) {
238
+			if (array_search($key, $model->getFillable(), true) !== false) {
239
+				/**
240
+				 * If the attribute isn't a relation and prevent attributes not in the fillable.
241
+				 */
242
+				$model->$key = $value;
243
+			}
244
+		}
245
+
246
+		return $model;
247
+	}
248 248
     
249
-    /**
250
-     * Prepare related models based on the given data for the given model.
251
-     *
252
-     * @param   array  $data
253
-     * @param   object $model
254
-     *
255
-     * @return  array
256
-     */
257
-    public function prepareRelations($data, $model)
258
-    {
259
-        /**
260
-         * Init the relation array
261
-         *
262
-         * @var array
263
-         */
264
-        $relations = [];
265
-
266
-        /**
267
-         * Construct the model object with the given data,
268
-         * and if there is a relation add it to relations array,
269
-         * then save the model.
270
-         */
271
-        foreach ($data as $key => $value) {
272
-            /**
273
-             * If the attribute is a relation.
274
-             */
275
-            $relation = \Str::camel($key);
276
-            if (method_exists($model, $relation) && \Core::$relation()) {
277
-                /**
278
-                 * Check if the relation is a collection.
279
-                 */
280
-                if (class_basename($model->$relation) == 'Collection') {
281
-                    /**
282
-                     * If the relation has no value then marke the relation data
283
-                     * related to the model to be deleted.
284
-                     */
285
-                    if (! $value || ! count($value)) {
286
-                        $relations[$relation] = 'delete';
287
-                    }
288
-                }
289
-                if (is_array($value)) {
290
-                    /**
291
-                     * Loop through the relation data.
292
-                     */
293
-                    foreach ($value as $attr => $val) {
294
-                        /**
295
-                         * Get the relation model.
296
-                         */
297
-                        $relationBaseModel = \Core::$relation()->model;
298
-
299
-                        /**
300
-                         * Check if the relation is a collection.
301
-                         */
302
-                        if (class_basename($model->$relation) == 'Collection') {
303
-                            /**
304
-                             * If the id is present in the data then select the relation model for updating,
305
-                             * else create new model.
306
-                             */
307
-                            $relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
308
-
309
-                            /**
310
-                             * If model doesn't exists.
311
-                             */
312
-                            if (! $relationModel) {
313
-                                \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
314
-                            }
315
-
316
-                            /**
317
-                             * Loop through the relation attributes.
318
-                             */
319
-                            foreach ($val as $attr => $val) {
320
-                                /**
321
-                                 * Prevent the sub relations or attributes not in the fillable.
322
-                                 */
323
-                                if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) {
324
-                                    $relationModel->$attr = $val;
325
-                                }
326
-                            }
327
-
328
-                            $relations[$relation][] = $relationModel;
329
-                        } else {
330
-                            /**
331
-                             * Prevent the sub relations.
332
-                             */
333
-                            if (gettype($val) !== 'object' && gettype($val) !== 'array') {
334
-                                /**
335
-                                 * If the id is present in the data then select the relation model for updating,
336
-                                 * else create new model.
337
-                                 */
338
-                                $relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
339
-
340
-                                /**
341
-                                 * If model doesn't exists.
342
-                                 */
343
-                                if (! $relationModel) {
344
-                                    \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
345
-                                }
346
-
347
-                                foreach ($value as $relationAttribute => $relationValue) {
348
-                                    /**
349
-                                     * Prevent attributes not in the fillable.
350
-                                     */
351
-                                    if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
352
-                                        $relationModel->$relationAttribute = $relationValue;
353
-                                    }
354
-                                }
355
-
356
-                                $relations[$relation] = $relationModel;
357
-                            }
358
-                        }
359
-                    }
360
-                }
361
-            }
362
-        }
363
-
364
-        return $relations;
365
-    }
366
-
367
-    /**
368
-     * Save the model with related models.
369
-     *
370
-     * @param   object  $model
371
-     * @param   array   $relations
372
-     *
373
-     * @return  object
374
-     */
375
-    public function saveModel($model, $relations)
376
-    {
377
-
378
-        /**
379
-         * Loop through the relations array.
380
-         */
381
-        foreach ($relations as $key => $value) {
382
-            /**
383
-             * If the relation is marked for delete then delete it.
384
-             */
385
-            if ($value == 'delete' && $model->$key()->count()) {
386
-                $model->$key()->delete();
387
-            } elseif (gettype($value) == 'array') {
388
-                /**
389
-                 * Save the model.
390
-                 */
391
-                $model->save();
392
-                $ids = [];
393
-
394
-                /**
395
-                 * Loop through the relations.
396
-                 */
397
-                foreach ($value as $val) {
398
-                    switch (class_basename($model->$key())) {
399
-                        /**
400
-                         * If the relation is one to many then update it's foreign key with
401
-                         * the model id and save it then add its id to ids array to delete all
402
-                         * relations who's id isn't in the ids array.
403
-                         */
404
-                        case 'HasMany':
405
-                            $foreignKeyName       = $model->$key()->getForeignKeyName();
406
-                            $val->$foreignKeyName = $model->id;
407
-                            $val->save();
408
-                            $ids[] = $val->id;
409
-                            break;
410
-
411
-                        /**
412
-                         * If the relation is many to many then add it's id to the ids array to
413
-                         * attache these ids to the model.
414
-                         */
415
-                        case 'BelongsToMany':
416
-                            $val->save();
417
-                            $ids[] = $val->id;
418
-                            break;
419
-                    }
420
-                }
421
-                switch (class_basename($model->$key())) {
422
-                    /**
423
-                     * If the relation is one to many then delete all
424
-                     * relations who's id isn't in the ids array.
425
-                     */
426
-                    case 'HasMany':
427
-                        $model->$key()->whereNotIn('id', $ids)->delete();
428
-                        break;
429
-
430
-                    /**
431
-                     * If the relation is many to many then
432
-                     * detach the previous data and attach
433
-                     * the ids array to the model.
434
-                     */
435
-                    case 'BelongsToMany':
436
-                        $model->$key()->detach();
437
-                        $model->$key()->attach($ids);
438
-                        break;
439
-                }
440
-            } else {
441
-                switch (class_basename($model->$key())) {
442
-                    /**
443
-                     * If the relation is one to one.
444
-                     */
445
-                    case 'HasOne':
446
-                        /**
447
-                         * Save the model.
448
-                         */
449
-                        $model->save();
450
-                        $foreignKeyName         = $model->$key()->getForeignKeyName();
451
-                        $value->$foreignKeyName = $model->id;
452
-                        $value->save();
453
-                        break;
454
-                    case 'BelongsTo':
455
-                        /**
456
-                         * Save the model.
457
-                         */
458
-                        $value->save();
459
-                        $model->$key()->associate($value);
460
-                        break;
461
-                }
462
-            }
463
-        }
464
-
465
-        /**
466
-         * Save the model.
467
-         */
468
-        $model->save();
469
-
470
-        return $model;
471
-    }
472
-
473
-    /**
474
-     * Build the conditions recursively for the retrieving methods.
475
-     * @param  array $conditions
476
-     * @return array
477
-     */
478
-    protected function constructConditions($conditions, $model)
479
-    {
480
-        $conditionString = '';
481
-        $conditionValues = [];
482
-        foreach ($conditions as $key => $value) {
483
-            if (Str::contains($key, '->')) {
484
-                $key = $this->wrapJsonSelector($key);
485
-            }
486
-
487
-            if ($key == 'and') {
488
-                $conditions       = $this->constructConditions($value, $model);
489
-                $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
490
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
491
-            } elseif ($key == 'or') {
492
-                $conditions       = $this->constructConditions($value, $model);
493
-                $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
494
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
495
-            } else {
496
-                if (is_array($value)) {
497
-                    $operator = $value['op'];
498
-                    if (strtolower($operator) == 'between') {
499
-                        $value1 = $value['val1'];
500
-                        $value2 = $value['val2'];
501
-                    } else {
502
-                        $value = Arr::get($value, 'val', '');
503
-                    }
504
-                } else {
505
-                    $operator = '=';
506
-                }
249
+	/**
250
+	 * Prepare related models based on the given data for the given model.
251
+	 *
252
+	 * @param   array  $data
253
+	 * @param   object $model
254
+	 *
255
+	 * @return  array
256
+	 */
257
+	public function prepareRelations($data, $model)
258
+	{
259
+		/**
260
+		 * Init the relation array
261
+		 *
262
+		 * @var array
263
+		 */
264
+		$relations = [];
265
+
266
+		/**
267
+		 * Construct the model object with the given data,
268
+		 * and if there is a relation add it to relations array,
269
+		 * then save the model.
270
+		 */
271
+		foreach ($data as $key => $value) {
272
+			/**
273
+			 * If the attribute is a relation.
274
+			 */
275
+			$relation = \Str::camel($key);
276
+			if (method_exists($model, $relation) && \Core::$relation()) {
277
+				/**
278
+				 * Check if the relation is a collection.
279
+				 */
280
+				if (class_basename($model->$relation) == 'Collection') {
281
+					/**
282
+					 * If the relation has no value then marke the relation data
283
+					 * related to the model to be deleted.
284
+					 */
285
+					if (! $value || ! count($value)) {
286
+						$relations[$relation] = 'delete';
287
+					}
288
+				}
289
+				if (is_array($value)) {
290
+					/**
291
+					 * Loop through the relation data.
292
+					 */
293
+					foreach ($value as $attr => $val) {
294
+						/**
295
+						 * Get the relation model.
296
+						 */
297
+						$relationBaseModel = \Core::$relation()->model;
298
+
299
+						/**
300
+						 * Check if the relation is a collection.
301
+						 */
302
+						if (class_basename($model->$relation) == 'Collection') {
303
+							/**
304
+							 * If the id is present in the data then select the relation model for updating,
305
+							 * else create new model.
306
+							 */
307
+							$relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
308
+
309
+							/**
310
+							 * If model doesn't exists.
311
+							 */
312
+							if (! $relationModel) {
313
+								\Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
314
+							}
315
+
316
+							/**
317
+							 * Loop through the relation attributes.
318
+							 */
319
+							foreach ($val as $attr => $val) {
320
+								/**
321
+								 * Prevent the sub relations or attributes not in the fillable.
322
+								 */
323
+								if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) {
324
+									$relationModel->$attr = $val;
325
+								}
326
+							}
327
+
328
+							$relations[$relation][] = $relationModel;
329
+						} else {
330
+							/**
331
+							 * Prevent the sub relations.
332
+							 */
333
+							if (gettype($val) !== 'object' && gettype($val) !== 'array') {
334
+								/**
335
+								 * If the id is present in the data then select the relation model for updating,
336
+								 * else create new model.
337
+								 */
338
+								$relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
339
+
340
+								/**
341
+								 * If model doesn't exists.
342
+								 */
343
+								if (! $relationModel) {
344
+									\Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
345
+								}
346
+
347
+								foreach ($value as $relationAttribute => $relationValue) {
348
+									/**
349
+									 * Prevent attributes not in the fillable.
350
+									 */
351
+									if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
352
+										$relationModel->$relationAttribute = $relationValue;
353
+									}
354
+								}
355
+
356
+								$relations[$relation] = $relationModel;
357
+							}
358
+						}
359
+					}
360
+				}
361
+			}
362
+		}
363
+
364
+		return $relations;
365
+	}
366
+
367
+	/**
368
+	 * Save the model with related models.
369
+	 *
370
+	 * @param   object  $model
371
+	 * @param   array   $relations
372
+	 *
373
+	 * @return  object
374
+	 */
375
+	public function saveModel($model, $relations)
376
+	{
377
+
378
+		/**
379
+		 * Loop through the relations array.
380
+		 */
381
+		foreach ($relations as $key => $value) {
382
+			/**
383
+			 * If the relation is marked for delete then delete it.
384
+			 */
385
+			if ($value == 'delete' && $model->$key()->count()) {
386
+				$model->$key()->delete();
387
+			} elseif (gettype($value) == 'array') {
388
+				/**
389
+				 * Save the model.
390
+				 */
391
+				$model->save();
392
+				$ids = [];
393
+
394
+				/**
395
+				 * Loop through the relations.
396
+				 */
397
+				foreach ($value as $val) {
398
+					switch (class_basename($model->$key())) {
399
+						/**
400
+						 * If the relation is one to many then update it's foreign key with
401
+						 * the model id and save it then add its id to ids array to delete all
402
+						 * relations who's id isn't in the ids array.
403
+						 */
404
+						case 'HasMany':
405
+							$foreignKeyName       = $model->$key()->getForeignKeyName();
406
+							$val->$foreignKeyName = $model->id;
407
+							$val->save();
408
+							$ids[] = $val->id;
409
+							break;
410
+
411
+						/**
412
+						 * If the relation is many to many then add it's id to the ids array to
413
+						 * attache these ids to the model.
414
+						 */
415
+						case 'BelongsToMany':
416
+							$val->save();
417
+							$ids[] = $val->id;
418
+							break;
419
+					}
420
+				}
421
+				switch (class_basename($model->$key())) {
422
+					/**
423
+					 * If the relation is one to many then delete all
424
+					 * relations who's id isn't in the ids array.
425
+					 */
426
+					case 'HasMany':
427
+						$model->$key()->whereNotIn('id', $ids)->delete();
428
+						break;
429
+
430
+					/**
431
+					 * If the relation is many to many then
432
+					 * detach the previous data and attach
433
+					 * the ids array to the model.
434
+					 */
435
+					case 'BelongsToMany':
436
+						$model->$key()->detach();
437
+						$model->$key()->attach($ids);
438
+						break;
439
+				}
440
+			} else {
441
+				switch (class_basename($model->$key())) {
442
+					/**
443
+					 * If the relation is one to one.
444
+					 */
445
+					case 'HasOne':
446
+						/**
447
+						 * Save the model.
448
+						 */
449
+						$model->save();
450
+						$foreignKeyName         = $model->$key()->getForeignKeyName();
451
+						$value->$foreignKeyName = $model->id;
452
+						$value->save();
453
+						break;
454
+					case 'BelongsTo':
455
+						/**
456
+						 * Save the model.
457
+						 */
458
+						$value->save();
459
+						$model->$key()->associate($value);
460
+						break;
461
+				}
462
+			}
463
+		}
464
+
465
+		/**
466
+		 * Save the model.
467
+		 */
468
+		$model->save();
469
+
470
+		return $model;
471
+	}
472
+
473
+	/**
474
+	 * Build the conditions recursively for the retrieving methods.
475
+	 * @param  array $conditions
476
+	 * @return array
477
+	 */
478
+	protected function constructConditions($conditions, $model)
479
+	{
480
+		$conditionString = '';
481
+		$conditionValues = [];
482
+		foreach ($conditions as $key => $value) {
483
+			if (Str::contains($key, '->')) {
484
+				$key = $this->wrapJsonSelector($key);
485
+			}
486
+
487
+			if ($key == 'and') {
488
+				$conditions       = $this->constructConditions($value, $model);
489
+				$conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
490
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
491
+			} elseif ($key == 'or') {
492
+				$conditions       = $this->constructConditions($value, $model);
493
+				$conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
494
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
495
+			} else {
496
+				if (is_array($value)) {
497
+					$operator = $value['op'];
498
+					if (strtolower($operator) == 'between') {
499
+						$value1 = $value['val1'];
500
+						$value2 = $value['val2'];
501
+					} else {
502
+						$value = Arr::get($value, 'val', '');
503
+					}
504
+				} else {
505
+					$operator = '=';
506
+				}
507 507
                 
508
-                if (strtolower($operator) == 'between') {
509
-                    $conditionString  .= $key.' >= ? and ';
510
-                    $conditionValues[] = $value1;
511
-
512
-                    $conditionString  .= $key.' <= ? {op} ';
513
-                    $conditionValues[] = $value2;
514
-                } elseif (strtolower($operator) == 'in') {
515
-                    $conditionValues  = array_merge($conditionValues, $value);
516
-                    $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
517
-                    $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
518
-                } elseif (strtolower($operator) == 'null') {
519
-                    $conditionString .= $key.' is null {op} ';
520
-                } elseif (strtolower($operator) == 'not null') {
521
-                    $conditionString .= $key.' is not null {op} ';
522
-                } elseif (strtolower($operator) == 'has') {
523
-                    $sql              = $model->withTrashed()->has($key)->toSql();
524
-                    $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
525
-                    $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} ';
526
-                    $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
527
-                } else {
528
-                    $conditionString  .= $key.' '.$operator.' ? {op} ';
529
-                    $conditionValues[] = $value;
530
-                }
531
-            }
532
-        }
533
-        $conditionString = '('.rtrim($conditionString, '{op} ').')';
534
-        return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
535
-    }
536
-
537
-    /**
538
-     * Wrap the given JSON selector.
539
-     *
540
-     * @param  string  $value
541
-     * @return string
542
-     */
543
-    protected function wrapJsonSelector($value)
544
-    {
545
-        $removeLast = strpos($value, ')');
546
-        $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
547
-        $path       = explode('->', $value);
548
-        $field      = array_shift($path);
549
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
550
-            return '"'.$part.'"';
551
-        })->implode('.'));
508
+				if (strtolower($operator) == 'between') {
509
+					$conditionString  .= $key.' >= ? and ';
510
+					$conditionValues[] = $value1;
511
+
512
+					$conditionString  .= $key.' <= ? {op} ';
513
+					$conditionValues[] = $value2;
514
+				} elseif (strtolower($operator) == 'in') {
515
+					$conditionValues  = array_merge($conditionValues, $value);
516
+					$inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
517
+					$conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
518
+				} elseif (strtolower($operator) == 'null') {
519
+					$conditionString .= $key.' is null {op} ';
520
+				} elseif (strtolower($operator) == 'not null') {
521
+					$conditionString .= $key.' is not null {op} ';
522
+				} elseif (strtolower($operator) == 'has') {
523
+					$sql              = $model->withTrashed()->has($key)->toSql();
524
+					$conditions       = $this->constructConditions($value, $model->$key()->getRelated());
525
+					$conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} ';
526
+					$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
527
+				} else {
528
+					$conditionString  .= $key.' '.$operator.' ? {op} ';
529
+					$conditionValues[] = $value;
530
+				}
531
+			}
532
+		}
533
+		$conditionString = '('.rtrim($conditionString, '{op} ').')';
534
+		return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
535
+	}
536
+
537
+	/**
538
+	 * Wrap the given JSON selector.
539
+	 *
540
+	 * @param  string  $value
541
+	 * @return string
542
+	 */
543
+	protected function wrapJsonSelector($value)
544
+	{
545
+		$removeLast = strpos($value, ')');
546
+		$value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
547
+		$path       = explode('->', $value);
548
+		$field      = array_shift($path);
549
+		$result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
550
+			return '"'.$part.'"';
551
+		})->implode('.'));
552 552
         
553
-        return $removeLast === false ? $result : $result.')';
554
-    }
553
+		return $removeLast === false ? $result : $result.')';
554
+	}
555 555
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function __construct($model)
23 23
     {
24
-        $this->model  = $model;
24
+        $this->model = $model;
25 25
     }
26 26
 
27 27
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $model      = false;
87 87
         $relations  = [];
88 88
 
89
-        \DB::transaction(function () use (&$model, &$relations, $data) {
89
+        \DB::transaction(function() use (&$model, &$relations, $data) {
90 90
             
91 91
             $model     = $this->prepareModel($data);
92 92
             $relations = $this->prepareRelations($data, $model);
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function delete($value, $attribute = 'id')
112 112
     {
113
-        \DB::transaction(function () use ($value, $attribute) {
114
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
113
+        \DB::transaction(function() use ($value, $attribute) {
114
+            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) {
115 115
                 $model->delete();
116 116
             });
117 117
         });
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $model = $this->model->onlyTrashed()->find($id);
203 203
 
204
-        if (! $model) {
204
+        if ( ! $model) {
205 205
             \Errors::notFound(class_basename($this->model).' with id : '.$id);
206 206
         }
207 207
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
          * @var array
226 226
          */
227 227
         $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
228
-        if (! $model) {
228
+        if ( ! $model) {
229 229
             \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
230 230
         }
231 231
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                      * If the relation has no value then marke the relation data
283 283
                      * related to the model to be deleted.
284 284
                      */
285
-                    if (! $value || ! count($value)) {
285
+                    if ( ! $value || ! count($value)) {
286 286
                         $relations[$relation] = 'delete';
287 287
                     }
288 288
                 }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                             /**
310 310
                              * If model doesn't exists.
311 311
                              */
312
-                            if (! $relationModel) {
312
+                            if ( ! $relationModel) {
313 313
                                 \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
314 314
                             }
315 315
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
                                 /**
341 341
                                  * If model doesn't exists.
342 342
                                  */
343
-                                if (! $relationModel) {
343
+                                if ( ! $relationModel) {
344 344
                                     \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
345 345
                                 }
346 346
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
547 547
         $path       = explode('->', $value);
548 548
         $field      = array_shift($path);
549
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
549
+        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
550 550
             return '"'.$part.'"';
551 551
         })->implode('.'));
552 552
         
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/Stubs/Module/DummyModel.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 
9 9
 class DummyModel extends Model
10 10
 {
11
-    use SoftDeletes;
12
-    protected $table    = 'DummyTableName';
13
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
14
-    protected $hidden   = ['deleted_at'];
15
-    protected $guarded  = ['id'];
16
-    protected $fillable = []; // Add attributes here
11
+	use SoftDeletes;
12
+	protected $table    = 'DummyTableName';
13
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
14
+	protected $hidden   = ['deleted_at'];
15
+	protected $guarded  = ['id'];
16
+	protected $fillable = []; // Add attributes here
17 17
     
18
-    public static function boot()
19
-    {
20
-        parent::boot();
21
-        DummyModel::observe(DummyObserver::class);
22
-    }
18
+	public static function boot()
19
+	{
20
+		parent::boot();
21
+		DummyModel::observe(DummyObserver::class);
22
+	}
23 23
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/UpdateLocaleAndTimezone.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
 
9 9
 class UpdateLocaleAndTimezone
10 10
 {
11
-    protected $session;
12
-    protected $auth;
11
+	protected $session;
12
+	protected $auth;
13 13
     
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   Session      $session
18
-     * @param   Auth         $auth
19
-     * @param   Errors       $errors
20
-     *
21
-     * @return  void
22
-     */
23
-    public function __construct(Session $session, Auth $auth)
24
-    {
25
-        $this->session = $session;
26
-        $this->auth = $auth;
27
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   Session      $session
18
+	 * @param   Auth         $auth
19
+	 * @param   Errors       $errors
20
+	 *
21
+	 * @return  void
22
+	 */
23
+	public function __construct(Session $session, Auth $auth)
24
+	{
25
+		$this->session = $session;
26
+		$this->auth = $auth;
27
+	}
28 28
 
29
-    /**
30
-     * Handle an incoming request.
31
-     *
32
-     * @param  \Illuminate\Http\Request  $request
33
-     * @param  \Closure  $next
34
-     * @return mixed
35
-     */
36
-    public function handle($request, Closure $next)
37
-    {
38
-        $update = false;
39
-        $user   = $this->auth->user();
40
-        if ($user) {
41
-            $locale   = $this->session->get('locale');
42
-            $timezone = $this->session->get('time-zone');
43
-            if ($locale && $locale !== 'all' && $locale !== $user->locale) {
44
-                $user->locale = $locale;
45
-                $update       = true;
46
-            }
29
+	/**
30
+	 * Handle an incoming request.
31
+	 *
32
+	 * @param  \Illuminate\Http\Request  $request
33
+	 * @param  \Closure  $next
34
+	 * @return mixed
35
+	 */
36
+	public function handle($request, Closure $next)
37
+	{
38
+		$update = false;
39
+		$user   = $this->auth->user();
40
+		if ($user) {
41
+			$locale   = $this->session->get('locale');
42
+			$timezone = $this->session->get('time-zone');
43
+			if ($locale && $locale !== 'all' && $locale !== $user->locale) {
44
+				$user->locale = $locale;
45
+				$update       = true;
46
+			}
47 47
     
48
-            if ($timezone && $timezone !== $user->timezone) {
49
-                $user->timezone = $timezone;
50
-                $update         = true;
51
-            }
48
+			if ($timezone && $timezone !== $user->timezone) {
49
+				$user->timezone = $timezone;
50
+				$update         = true;
51
+			}
52 52
     
53
-            if ($update) {
54
-                $user->save();
55
-            }
56
-        }
53
+			if ($update) {
54
+				$user->save();
55
+			}
56
+		}
57 57
 
58
-        return $next($request);
59
-    }
58
+		return $next($request);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/SetSessions.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -8,39 +8,39 @@
 block discarded – undo
8 8
 
9 9
 class SetSessions
10 10
 {
11
-    protected $app;
12
-    protected $session;
11
+	protected $app;
12
+	protected $session;
13 13
     
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   App      $app
18
-     * @param   Session  $session
19
-     *
20
-     * @return  void
21
-     */
22
-    public function __construct(App $app, Session $session)
23
-    {
24
-        $this->app = $app;
25
-        $this->session = $session;
26
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   App      $app
18
+	 * @param   Session  $session
19
+	 *
20
+	 * @return  void
21
+	 */
22
+	public function __construct(App $app, Session $session)
23
+	{
24
+		$this->app = $app;
25
+		$this->session = $session;
26
+	}
27 27
 
28
-    /**
29
-     * Handle an incoming request.
30
-     *
31
-     * @param  \Illuminate\Http\Request  $request
32
-     * @param  \Closure  $next
33
-     * @return mixed
34
-     */
35
-    public function handle($request, Closure $next)
36
-    {
37
-        $locale = $request->header('locale', 'en');
38
-        $timeZone = $request->header('time-zone', 0);
28
+	/**
29
+	 * Handle an incoming request.
30
+	 *
31
+	 * @param  \Illuminate\Http\Request  $request
32
+	 * @param  \Closure  $next
33
+	 * @return mixed
34
+	 */
35
+	public function handle($request, Closure $next)
36
+	{
37
+		$locale = $request->header('locale', 'en');
38
+		$timeZone = $request->header('time-zone', 0);
39 39
 
40
-        $this->session->put('time-zone', $timeZone);
41
-        $this->session->put('locale', $locale);
42
-        $this->app->setLocale($locale);
40
+		$this->session->put('time-zone', $timeZone);
41
+		$this->session->put('locale', $locale);
42
+		$this->app->setLocale($locale);
43 43
 
44
-        return $next($request);
45
-    }
44
+		return $next($request);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/Modules/Permissions/Permission.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,21 +10,21 @@
 block discarded – undo
10 10
 class Permission extends Model
11 11
 {
12 12
 
13
-    use SoftDeletes;
14
-    protected $table    = 'permissions';
15
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
-    protected $hidden   = ['deleted_at'];
17
-    protected $guarded  = ['id'];
18
-    protected $fillable = ['name', 'model'];
13
+	use SoftDeletes;
14
+	protected $table    = 'permissions';
15
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
+	protected $hidden   = ['deleted_at'];
17
+	protected $guarded  = ['id'];
18
+	protected $fillable = ['name', 'model'];
19 19
     
20
-    public function roles()
21
-    {
22
-        return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps();
23
-    }
20
+	public function roles()
21
+	{
22
+		return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps();
23
+	}
24 24
 
25
-    public static function boot()
26
-    {
27
-        parent::boot();
28
-        Permission::observe(PermissionObserver::class);
29
-    }
25
+	public static function boot()
26
+	{
27
+		parent::boot();
28
+		Permission::observe(PermissionObserver::class);
29
+	}
30 30
 }
Please login to merge, or discard this patch.