123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Http\Requests\API\Task;
- use App\Http\Requests\RuleHelper;
- use function DragonCode\Support\Http\exists;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class BatchCreateRequest extends FormRequest
- {
- use RuleHelper;
- /**
- * Determine if the user is authorized to make this request.
- */
- public function authorize(): bool
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
- */
- public function rules(): array
- {
- return [
- 'project_id' => [
- 'required',
- Rule::exists('projects', 'id')->where($this->userCompanyWhere()),
- ],
- 'parent_id' => [
- 'required',
- Rule::when(
- $this->get('parent_id') != 0,
- Rule::exists('tasks', 'id')->where(function ($query) {
- $this->userCompanyWhere($query);
- })
- ),
- ],
- 'items' => [
- 'required', 'array'
- ]
- ];
- }
- }
|