*/ public static function forKind(string $kind): array { abort_unless(in_array($kind, ['demands', 'capacities'], true), 404); $demand = $kind === 'demands'; return [ 'occupation_id' => ['required', 'uuid', Rule::exists('occupations', 'id')->whereNull('deleted_at')], 'skill_id' => ['required', 'uuid', Rule::exists('skills', 'id')->whereNull('deleted_at')], 'geo_location_id' => ['required', 'uuid', Rule::exists('geo_locations', 'id')->whereNull('deleted_at')->whereIn('location_type', ['province', 'district', 'admin_post', 'locality'])], $demand ? 'project_id' : 'course_id' => ['required', 'uuid', $demand ? Rule::exists('projects', 'id')->whereNull('deleted_at') : Rule::exists('courses', 'id')->whereNull('deleted_at')->whereNot('status', 'retired')->where(fn ($query) => $query->whereIn('provider_id', TrainingProvider::where('status', '!=', 'inactive')->select('id')))], 'employer' => [$demand ? 'required' : 'exclude', 'string', 'max:200'], 'qualification' => ['required', 'string', 'max:150'], 'quantity' => ['required', 'integer', 'min:1', 'max:10000000'], 'period_start' => ['required', 'date_format:Y-m-d'], 'period_end' => ['required', 'date_format:Y-m-d', 'after_or_equal:period_start'], 'source' => ['required', 'string', 'min:10', 'max:5000'], 'reference_date' => ['required', 'date_format:Y-m-d', 'before_or_equal:today'], 'valid_until' => ['required', 'date_format:Y-m-d', 'after_or_equal:reference_date'], ]; } }