Akaunting/app/Http/Requests/Setting/Category.php

31 lines
796 B
PHP
Raw Normal View History

2017-09-14 19:21:00 +00:00
<?php
namespace App\Http\Requests\Setting;
2019-11-16 07:21:14 +00:00
use App\Abstracts\Http\FormRequest;
2017-09-14 19:21:00 +00:00
2019-11-16 07:21:14 +00:00
class Category extends FormRequest
2017-09-14 19:21:00 +00:00
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$types = collect(config('type.category'))->keys();
$type = $this->request->get('type');
$config = config('type.category.' . $type, []);
$code_hidden = !empty($config['hide']) && in_array('code', $config['hide']);
$code = $code_hidden ? 'nullable|string' : 'required|string';
2017-09-14 19:21:00 +00:00
return [
'name' => 'required|string',
'code' => $code,
'type' => 'required|string|in:' . $types->implode(','),
2024-02-09 08:37:16 +00:00
'color' => 'required|string|colour',
2017-09-14 19:21:00 +00:00
];
}
}