<?php

namespace Modules\Projects\Http\Requests;

use App\Rules\EstimatedHours;
use Illuminate\Foundation\Http\FormRequest;

/**
 * Class UpdateProjectRequest
 *
 * The Validation Rules is Defined for Project.
 *
 * PHP version 8.2
 *
 * @category  PM
 * @package   Modules\Projects
 * @author    Vipul Patel <vipul@chetsapp.com>
 * @copyright 2019 Chetsapp Group
 * @license   Chetsapp Private Limited
 * @version   Release: @1.0@
 * @link      https://www.chetsapp.com
 * @since     Class available since Release 1.0
 */
class UpdateProjectRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->segment(3);
        return [
            'project_name' => 'required|max:' . config('core.max_length') . '|unique:' .
            config('core.acl.projects_table') . ',project_name,' . $id . ',id,deleted_at,NULL',
            'project_version' => 'required',
            'status' => 'required',
            'start_date' => 'required|date',
            'end_date' => 'required|date|after_or_equal:start_date',
            'billing_type' => 'nullable|integer',
            'demo_url' => 'url|nullable',
            'estimated_hours' => ['nullable', new EstimatedHours],
            'price_rate' => 'nullable|numeric',
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
