first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace Modules\Option\Http\Requests;
use Illuminate\Validation\Rule;
use Modules\Option\Entities\Option;
use Modules\Core\Http\Requests\Request;
class SaveOptionRequest extends Request
{
/**
* Available attributes.
*
* @var string
*/
protected $availableAttributes = 'option::attributes';
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => ['required', Rule::in(Option::TYPES)],
'is_required' => 'required|boolean',
'values.*.label' => 'required_if:options.*.type,dropdown,checkbox,checkbox_custom,radio,radio_custom,multiple_select',
'values.*.price' => 'nullable|numeric|min:0|max:99999999999999',
'values.*.price_type' => ['required', Rule::in(['fixed', 'percent'])],
];
}
public function validationData()
{
return request()->merge([
'values' => $this->filter($this->values ?? []),
])->all();
}
private function filter($values = [])
{
return array_filter($values, function ($value) {
if (! array_has($value, 'label')) {
return true;
}
return ! is_null($value['label']);
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Modules\Option\Http\Requests;
use Illuminate\Validation\Rule;
use Modules\Option\Entities\Option;
use Modules\Core\Http\Requests\Request;
class SaveProductOptionsRequest extends Request
{
/**
* Available attributes.
*
* @var string
*/
protected $availableAttributes = 'option::attributes';
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'options.*.name' => 'required_with:options.*.type',
'options.*.type' => ['nullable', 'required_with:options.*.name', Rule::in(Option::TYPES)],
'options.*.is_required' => ['required_with:options.*.name', 'boolean'],
'options.*.values.*.label' => 'required_if:options.*.type,dropdown,checkbox,checkbox_custom,radio,radio_custom,multiple_select',
'options.*.values.*.price' => 'nullable|numeric|min:0|max:99999999999999',
'options.*.values.*.price_type' => ['required', Rule::in(['fixed', 'percent'])],
];
}
}