user()->isAdmin(); // TODO permissions } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'name' => 'required|string', 'node_align' => 'integer', 'width_type' => 'in:px,%', 'width' => [ function (string $attribute, mixed $value, Closure $fail) { if (! preg_match('/^(\d+)(px|%)$/', $value, $matches)) { $fail(__('map.custom.edit.validate.width_format')); } elseif ($matches[2] == 'px' && $matches[1] < 200) { $fail(__('map.custom.edit.validate.width_pixels')); } elseif ($matches[2] == '%' && ($matches[1] < 10 || $matches[1] > 100)) { $fail(__('map.custom.edit.validate.width_percent')); } }, ], 'height_type' => 'in:px,%', 'height' => [ function (string $attribute, mixed $value, Closure $fail) { if (! preg_match('/^(\d+)(px|%)$/', $value, $matches)) { $fail(__('map.custom.edit.validate.height_format')); } elseif ($matches[2] == 'px' && $matches[1] < 200) { $fail(__('map.custom.edit.validate.height_pixels')); } elseif ($matches[2] == '%' && ($matches[1] < 10 || $matches[1] > 100)) { $fail(__('map.custom.edit.validate.height_percent')); } }, ], ]; } }