4 changed files with 58 additions and 138 deletions
-
38app/Entities/Options/OptionsRepository.php
-
57app/Http/Controllers/References/OptionsController.php
-
31app/Http/Requests/Options/CreateRequest.php
-
2routes/web/references.php
@ -1,38 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Options; |
|||
|
|||
use App\Entities\BaseRepository; |
|||
use App\Exceptions\OptionNotFoundException; |
|||
use App\Exceptions\OptionUpdateException; |
|||
use App\Exceptions\OptionDeleteException; |
|||
|
|||
/** |
|||
* Options Repository Class |
|||
*/ |
|||
class OptionsRepository extends BaseRepository |
|||
{ |
|||
protected $model; |
|||
|
|||
public function __construct(Option $model) |
|||
{ |
|||
parent::__construct($model); |
|||
} |
|||
|
|||
public function getAll($q = null) |
|||
{ |
|||
return Option::all(); |
|||
} |
|||
|
|||
public function save($optionsData) |
|||
{ |
|||
$options = $this->getAll(); |
|||
foreach ($optionsData as $key => $value) { |
|||
$option = $options->where('key', $key)->first(); |
|||
$option->value = $value; |
|||
$option->save(); |
|||
} |
|||
|
|||
return 'saved'; |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Requests\Options; |
|||
|
|||
use App\Http\Requests\Request; |
|||
|
|||
class CreateRequest extends Request |
|||
{ |
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return auth()->user()->can('manage_options'); |
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
'key' => 'required|max:255|alpha_dash', |
|||
'value' => 'max:255', |
|||
]; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue