<?php

namespace App\PackagesAdmin\User\Requests;

use Illuminate\Foundation\Http\FormRequest;

/**
 * Class ChangeUserRequest
 * @package App\PackagesAdmin\User\Requests
 *
 * @property string $first_name
 * @property string $last_name
 * @property string $nickname
 * @property string $email
 * @property string $phone_number
 * @property bool $push_notification
 * @property bool $is_suggested
 * @property integer $suggested_position
 * @property integer $search_position
 */
class ChangeUserRequest extends FormRequest
{
    /**
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * @return array
     */
    public function rules()
    {
        $id = $this->route('id');

        return [
            'first_name' => ['string', 'nullable', 'max:255'],
            'last_name' => ['string', 'nullable', 'max:255'],
            'nickname' => ['string', 'nullable', 'max:255', 'unique:table_user,nickname,' . $id],
            'email' => ['email', 'required', 'max:255'],
            'phone_number' => ['string', 'nullable'],
            'push_notification' => ['boolean'],
            'is_suggested' => ['boolean'],
            'suggested_position' => ['integer', 'nullable'],
            'search_position' => ['integer', 'nullable'],
        ];
    }
}
