@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ClearDataSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
| 17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | - $permissions->delete(); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
| 17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -6,76 +6,76 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SettingsTableSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - /** |
|
| 17 | - * Insert the permissions related to settings table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * Settings model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'save', |
|
| 26 | - 'model' => 'settings', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'find', |
|
| 32 | - 'model' => 'settings', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - [ |
|
| 37 | - 'name' => 'search', |
|
| 38 | - 'model' => 'settings', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'list', |
|
| 44 | - 'model' => 'settings', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'findby', |
|
| 50 | - 'model' => 'settings', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'first', |
|
| 56 | - 'model' => 'settings', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'paginate', |
|
| 62 | - 'model' => 'settings', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ], |
|
| 66 | - [ |
|
| 67 | - 'name' => 'paginateby', |
|
| 68 | - 'model' => 'settings', |
|
| 69 | - 'created_at' => \DB::raw('NOW()'), |
|
| 70 | - 'updated_at' => \DB::raw('NOW()') |
|
| 71 | - ], |
|
| 72 | - [ |
|
| 73 | - 'name' => 'saveMany', |
|
| 74 | - 'model' => 'settings', |
|
| 75 | - 'created_at' => \DB::raw('NOW()'), |
|
| 76 | - 'updated_at' => \DB::raw('NOW()') |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ); |
|
| 80 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to settings table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * Settings model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'save', |
|
| 26 | + 'model' => 'settings', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'find', |
|
| 32 | + 'model' => 'settings', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + [ |
|
| 37 | + 'name' => 'search', |
|
| 38 | + 'model' => 'settings', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'list', |
|
| 44 | + 'model' => 'settings', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'findby', |
|
| 50 | + 'model' => 'settings', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'first', |
|
| 56 | + 'model' => 'settings', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'paginate', |
|
| 62 | + 'model' => 'settings', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ], |
|
| 66 | + [ |
|
| 67 | + 'name' => 'paginateby', |
|
| 68 | + 'model' => 'settings', |
|
| 69 | + 'created_at' => \DB::raw('NOW()'), |
|
| 70 | + 'updated_at' => \DB::raw('NOW()') |
|
| 71 | + ], |
|
| 72 | + [ |
|
| 73 | + 'name' => 'saveMany', |
|
| 74 | + 'model' => 'settings', |
|
| 75 | + 'created_at' => \DB::raw('NOW()'), |
|
| 76 | + 'updated_at' => \DB::raw('NOW()') |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('settings', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name',100); |
|
| 18 | - $table->string('key',100)->unique(); |
|
| 19 | - $table->text('value')->nullable(); |
|
| 20 | - $table->softDeletes(); |
|
| 21 | - $table->timestamps(); |
|
| 22 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name',100); |
|
| 18 | + $table->string('key',100)->unique(); |
|
| 19 | + $table->text('value')->nullable(); |
|
| 20 | + $table->softDeletes(); |
|
| 21 | + $table->timestamps(); |
|
| 22 | + }); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\Core\Settings::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
| 6 | 6 | 'value' => $faker->word(), |
| 7 | 7 | 'key' => $faker->word(), |
| 8 | 8 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 9 | 9 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 10 | - ]; |
|
| 10 | + ]; |
|
| 11 | 11 | }); |
@@ -5,37 +5,37 @@ |
||
| 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']; |
|
| 14 | - public $searchable = ['name', 'value', 'key']; |
|
| 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 | + public $searchable = ['name', 'value', 'key']; |
|
| 15 | 15 | |
| 16 | - public function getCreatedAtAttribute($value) |
|
| 17 | - { |
|
| 18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | - } |
|
| 16 | + public function getCreatedAtAttribute($value) |
|
| 17 | + { |
|
| 18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getUpdatedAtAttribute($value) |
|
| 22 | - { |
|
| 23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | - } |
|
| 21 | + public function getUpdatedAtAttribute($value) |
|
| 22 | + { |
|
| 23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function getDeletedAtAttribute($value) |
|
| 27 | - { |
|
| 28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | - } |
|
| 26 | + public function getDeletedAtAttribute($value) |
|
| 27 | + { |
|
| 28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function newCollection(array $models = []) |
|
| 32 | - { |
|
| 33 | - return parent::newCollection($models)->keyBy('key'); |
|
| 34 | - } |
|
| 31 | + public function newCollection(array $models = []) |
|
| 32 | + { |
|
| 33 | + return parent::newCollection($models)->keyBy('key'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public static function boot() |
|
| 37 | - { |
|
| 38 | - parent::boot(); |
|
| 39 | - parent::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 40 | - } |
|
| 36 | + public static function boot() |
|
| 37 | + { |
|
| 38 | + parent::boot(); |
|
| 39 | + parent::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -2,118 +2,118 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface RepositoryInterface |
| 4 | 4 | { |
| 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 | - */ |
|
| 14 | - public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 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 | + */ |
|
| 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 | - /** |
|
| 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('*')); |
|
| 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('*')); |
|
| 41 | 41 | |
| 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('*')); |
|
| 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('*')); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Save the given model/models to the storage. |
|
| 58 | - * |
|
| 59 | - * @param array $data |
|
| 60 | - * @return object |
|
| 61 | - */ |
|
| 62 | - public function save(array $data); |
|
| 56 | + /** |
|
| 57 | + * Save the given model/models to the storage. |
|
| 58 | + * |
|
| 59 | + * @param array $data |
|
| 60 | + * @return object |
|
| 61 | + */ |
|
| 62 | + public function save(array $data); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Update record in the storage based on the given |
|
| 66 | - * condition. |
|
| 67 | - * |
|
| 68 | - * @param var $value condition value |
|
| 69 | - * @param array $data |
|
| 70 | - * @param string $attribute condition column name |
|
| 71 | - * @return integer affected rows |
|
| 72 | - */ |
|
| 73 | - public function update($value, array $data, $attribute = 'id'); |
|
| 64 | + /** |
|
| 65 | + * Update record in the storage based on the given |
|
| 66 | + * condition. |
|
| 67 | + * |
|
| 68 | + * @param var $value condition value |
|
| 69 | + * @param array $data |
|
| 70 | + * @param string $attribute condition column name |
|
| 71 | + * @return integer affected rows |
|
| 72 | + */ |
|
| 73 | + public function update($value, array $data, $attribute = 'id'); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Delete record from the storage based on the given |
|
| 77 | - * condition. |
|
| 78 | - * |
|
| 79 | - * @param var $value condition value |
|
| 80 | - * @param string $attribute condition column name |
|
| 81 | - * @return integer affected rows |
|
| 82 | - */ |
|
| 83 | - public function delete($value, $attribute = 'id'); |
|
| 75 | + /** |
|
| 76 | + * Delete record from the storage based on the given |
|
| 77 | + * condition. |
|
| 78 | + * |
|
| 79 | + * @param var $value condition value |
|
| 80 | + * @param string $attribute condition column name |
|
| 81 | + * @return integer affected rows |
|
| 82 | + */ |
|
| 83 | + public function delete($value, $attribute = 'id'); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Fetch records from the storage based on the given |
|
| 87 | - * id. |
|
| 88 | - * |
|
| 89 | - * @param integer $id |
|
| 90 | - * @param array $relations |
|
| 91 | - * @param array $columns |
|
| 92 | - * @return object |
|
| 93 | - */ |
|
| 94 | - public function find($id, $relations = [], $columns = array('*')); |
|
| 85 | + /** |
|
| 86 | + * Fetch records from the storage based on the given |
|
| 87 | + * id. |
|
| 88 | + * |
|
| 89 | + * @param integer $id |
|
| 90 | + * @param array $relations |
|
| 91 | + * @param array $columns |
|
| 92 | + * @return object |
|
| 93 | + */ |
|
| 94 | + public function find($id, $relations = [], $columns = array('*')); |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Fetch records from the storage based on the given |
|
| 98 | - * condition. |
|
| 99 | - * |
|
| 100 | - * @param array $conditions array of conditions |
|
| 101 | - * @param array $relations |
|
| 102 | - * @param array $sortBy |
|
| 103 | - * @param array $desc |
|
| 104 | - * @param array $columns |
|
| 105 | - * @return collection |
|
| 106 | - */ |
|
| 107 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 96 | + /** |
|
| 97 | + * Fetch records from the storage based on the given |
|
| 98 | + * condition. |
|
| 99 | + * |
|
| 100 | + * @param array $conditions array of conditions |
|
| 101 | + * @param array $relations |
|
| 102 | + * @param array $sortBy |
|
| 103 | + * @param array $desc |
|
| 104 | + * @param array $columns |
|
| 105 | + * @return collection |
|
| 106 | + */ |
|
| 107 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Fetch the first record fro the storage based on the given |
|
| 111 | - * condition. |
|
| 112 | - * |
|
| 113 | - * @param array $conditions array of conditions |
|
| 114 | - * @param array $relations |
|
| 115 | - * @param array $columns |
|
| 116 | - * @return object |
|
| 117 | - */ |
|
| 118 | - public function first($conditions, $relations = [], $columns = array('*')); |
|
| 109 | + /** |
|
| 110 | + * Fetch the first record fro the storage based on the given |
|
| 111 | + * condition. |
|
| 112 | + * |
|
| 113 | + * @param array $conditions array of conditions |
|
| 114 | + * @param array $relations |
|
| 115 | + * @param array $columns |
|
| 116 | + * @return object |
|
| 117 | + */ |
|
| 118 | + public function first($conditions, $relations = [], $columns = array('*')); |
|
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |
@@ -8,31 +8,31 @@ |
||
| 8 | 8 | |
| 9 | 9 | class SettingsController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The name of the model that is used by the base api controller |
|
| 13 | - * to preform actions like (add, edit ... etc). |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $model = 'settings'; |
|
| 11 | + /** |
|
| 12 | + * The name of the model that is used by the base api controller |
|
| 13 | + * to preform actions like (add, edit ... etc). |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $model = 'settings'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * The validations rules used by the base api controller |
|
| 20 | - * to check before add. |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $validationRules = [ |
|
| 24 | - 'id' => 'required|exists:settings,id', |
|
| 25 | - 'value' => 'required|string' |
|
| 26 | - ]; |
|
| 18 | + /** |
|
| 19 | + * The validations rules used by the base api controller |
|
| 20 | + * to check before add. |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $validationRules = [ |
|
| 24 | + 'id' => 'required|exists:settings,id', |
|
| 25 | + 'value' => 'required|string' |
|
| 26 | + ]; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Save list of settings. |
|
| 30 | - * |
|
| 31 | - * @param \Illuminate\Http\Request $request |
|
| 32 | - * @return \Illuminate\Http\Response |
|
| 33 | - */ |
|
| 34 | - public function saveMany(Request $request) |
|
| 35 | - { |
|
| 36 | - return \Response::json($this->repo->saveMany($request->all()), 200); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * Save list of settings. |
|
| 30 | + * |
|
| 31 | + * @param \Illuminate\Http\Request $request |
|
| 32 | + * @return \Illuminate\Http\Response |
|
| 33 | + */ |
|
| 34 | + public function saveMany(Request $request) |
|
| 35 | + { |
|
| 36 | + return \Response::json($this->repo->saveMany($request->all()), 200); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -5,68 +5,68 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class SettingsObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Prevent the creating of the settings. |
|
| 20 | - * |
|
| 21 | - * @param object $model the model beign created. |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function creating($model) |
|
| 25 | - { |
|
| 26 | - \ErrorHandler::cannotCreateSetting(); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * Prevent the creating of the settings. |
|
| 20 | + * |
|
| 21 | + * @param object $model the model beign created. |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function creating($model) |
|
| 25 | + { |
|
| 26 | + \ErrorHandler::cannotCreateSetting(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function created($model) |
|
| 30 | - { |
|
| 31 | - // |
|
| 32 | - } |
|
| 29 | + public function created($model) |
|
| 30 | + { |
|
| 31 | + // |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Prevent updating of the setting key. |
|
| 36 | - * |
|
| 37 | - * @param object $model the model beign updated. |
|
| 38 | - * @return void |
|
| 39 | - */ |
|
| 40 | - public function updating($model) |
|
| 41 | - { |
|
| 42 | - if ($model->getOriginal('key') !== $model->key) |
|
| 43 | - { |
|
| 44 | - \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 34 | + /** |
|
| 35 | + * Prevent updating of the setting key. |
|
| 36 | + * |
|
| 37 | + * @param object $model the model beign updated. |
|
| 38 | + * @return void |
|
| 39 | + */ |
|
| 40 | + public function updating($model) |
|
| 41 | + { |
|
| 42 | + if ($model->getOriginal('key') !== $model->key) |
|
| 43 | + { |
|
| 44 | + \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function updated($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 48 | + public function updated($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function deleting($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 53 | + public function deleting($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function deleted($model) |
|
| 59 | - { |
|
| 60 | - // |
|
| 61 | - } |
|
| 58 | + public function deleted($model) |
|
| 59 | + { |
|
| 60 | + // |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function restoring($model) |
|
| 64 | - { |
|
| 65 | - // |
|
| 66 | - } |
|
| 63 | + public function restoring($model) |
|
| 64 | + { |
|
| 65 | + // |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function restored($model) |
|
| 69 | - { |
|
| 70 | - // |
|
| 71 | - } |
|
| 68 | + public function restored($model) |
|
| 69 | + { |
|
| 70 | + // |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |
@@ -14,19 +14,19 @@ |
||
| 14 | 14 | return 'App\Modules\Core\Settings'; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Save list of settings. |
|
| 19 | - * |
|
| 20 | - * @param array $data |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function saveMany(array $data) |
|
| 24 | - { |
|
| 25 | - \DB::transaction(function () use ($data) { |
|
| 26 | - foreach ($data as $key => $value) |
|
| 27 | - { |
|
| 28 | - $this->save($value); |
|
| 29 | - } |
|
| 30 | - }); |
|
| 31 | - } |
|
| 17 | + /** |
|
| 18 | + * Save list of settings. |
|
| 19 | + * |
|
| 20 | + * @param array $data |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function saveMany(array $data) |
|
| 24 | + { |
|
| 25 | + \DB::transaction(function () use ($data) { |
|
| 26 | + foreach ($data as $key => $value) |
|
| 27 | + { |
|
| 28 | + $this->save($value); |
|
| 29 | + } |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |