1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Http\Requests\API\Plan;
- use App\Http\Requests\RuleHelper;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class CreateOrUpdateRequest 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 [
- 'asset_id' => [
- 'required',
- Rule::exists('assets', 'id')->where($this->userCompanyWhere()),
- ],
- 'title' => 'required|max:255',
- 'begin' => 'date',
- 'end' => 'date',
- 'parent_id' => [
- Rule::exists('plans', 'id')->where($this->userCompanyWhere())->where("asset_id", $this->post("asset_id")),
- ]
- ];
- }
- }
|