<?php

namespace App\Http\Requests\Employee;

use App\Models\Career;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class CareerRequest 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 [
            'career_code' => ['required', 'string', 'max:255'],
            'career_title' => ['required', 'string', 'max:255', Rule::unique(Career::class)->ignore($this->careers)],
            'departments' => ['required'],
            'career_description' => ['required'],
            'is_specific' => ['required'],
            'image_url' => ['required', 'image', 'mimes:jpeg,png,jpg', 'max:2048']
        ];
    }

    public function messages(): array
    {
        return [
            'career_code.required' => 'Kode karir harus diisi.',
            'career_code.string' => 'Kode karir harus berupa teks.',
            'career_code.max' => 'Kode karir tidak boleh lebih dari 255 karakter.',
            'career_title.required' => 'Judul karir harus diisi.',
            'career_title.string' => 'Judul karir harus berupa teks.',
            'career_title.max' => 'Judul karir tidak boleh lebih dari 255 karakter.',
            'career_title.unique' => 'Judul karir telah digunakan.',
            'departments.required' => 'Jurusan harus dipilih.',
            'career_description.required' => 'Deskripsi karir harus diisi.',
            'is_specific.required' => 'Tipe Karier harus dipilih.',
            'image_url.required' => 'Gambar harus diisi.',
            'image_url.image' => 'File harus berupa gambar.',
            'image_url.mimes' => 'Gambar harus berformat jpeg, png, jpg.',
            'image_url.max' => 'Gambar tidak boleh lebih dari 2MB.'
        ];
    }
}
