<?php

namespace App\Http\Traits;

use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Validator;

trait AuthValidationTraits
{
    public function validateRegisterUser($postData)
    {
        $validation = Validator::make($postData->all(), [
            'name' => 'required',
            'password' => 'required|min:8',
            'email' => 'required|email|unique:users,email,' . Request::get("id"),
            'country' => 'nullable|numeric',
            'mobile_no' => 'required|numeric',
            'image' => "nullable|mimes:jpg,png,jpeg",
        ]);

        return $validation;
    }

    public function validateEmail($postData)
    {
        $validation = validator::make($postData->all(), [
            'email' => 'required|email'
        ]);

        return $validation;
    }

    public function validatePassword($postData)
    {
        $validation = validator::make($postData->all(), [
            'newPassword' => 'required',
        ]);

        return $validation;
    }

    public function validateProfileUpdate($postData)
    {
        $validation = Validator::make($postData->all(), [
            'name' => 'required',
            'email' => 'required|email|unique:users,email,' . \Request::get("id"),
            "image" => "nullable|mimes:jpg,png,jpeg",
        ]);

        return $validation;
    }
}
