1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Http\Requests\API\Project;
- use App\Models\Asset;
- use App\Models\Enums\AssetStatus;
- use App\Models\Plan;
- use App\Models\User;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Validation\Rule;
- use Illuminate\Validation\Rules\Enum;
- class UpdateLinkAssetsRequest extends FormRequest
- {
- /**
- * 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' =>[
- 'email'
- ],
- 'assets' => [
- 'array',
- function ($attribute, $value, $fail) {
- $assetIds = Asset::query()->whereIn('id', $value)->pluck('id')->toArray();
- if (count(array_diff($value, $assetIds)) > 0) {
- $fail('The selected asset is invalid.');
- }
- }
- ],
- ];
- }
- }
|