v2 first commit
This commit is contained in:
40
app/Http/Requests/Setting/Module.php
Normal file
40
app/Http/Requests/Setting/Module.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Setting;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Module extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
$module = module($this->request->get('module_alias'));
|
||||
|
||||
if ($module->get('settings')) {
|
||||
foreach ($module->get('settings') as $field) {
|
||||
if (isset($field['attributes']['required'])) {
|
||||
$rules[$field['name']] = $field['attributes']['required'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user