<?php
namespace App\Services\Auth\Login;
use Illuminate\Support\Facades\Auth;
use App\Models\User;

class LoginEmailService implements LoginInterface
{
    public function authLogin($requestContent) :array
    {
        $status = 400;
        $message = [__('web.checkinputs')];
        $target = route('login');

        $remember = isset($requestContent['remember']) ? true : false;
        $user = User::onlyTrashed()->where('email',$requestContent['target'])->first();
        if($user)
        {
            $message = [__('web.not_actived')];
        }
        if (Auth::attempt(['email' => $requestContent['target'], 'password' => $requestContent['password']], $remember))
        {
            $status = 200;
            $message = __('web.success');
            $target = route('home');
        }
        $response =
        [
            'status' => $status,
            'message' => $message,
            'data'=>$target,
        ];
        return $response;
    }
}
