<?php

namespace App\Modules\Jobseeker;

use App\Models\PasswordResets;
use App\Models\Worker;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use App\Http\Resources\Jobseeker\Account as AccountResource;

class Account
{

    public $userData;

    public function __construct()
    {
        $this->userData = Auth::user();
    }

    public function fetchDetails()
    {
        $userId = $this->userData->id;

        return AccountResource::collection(
            Worker::select(
                'workers.id',
                'workers.email_address',
                'workers.first_name',
                'workers.last_name',
                'workers.phone_num',
                DB::raw('CONCAT(first_name, " ", last_name) as name'),
                DB::raw('CONCAT(street_address, ", ", city, ", ", state, ", " , zipcode) as address'),
                'workers.created_at',
                'workers.street_address',
                'workers.city',
                'workers.state',
                'workers.zipcode',
                'workers.distance',
                'workers.profile_picture',
                'workers.availability_start_date',
                'workers.availability_end_date',
                // 'workers.resume_file_name as resume',
                'workers.email_verified_at',
            )
                ->with('jobseeker_work_area_lists')
                ->with('get_jobseeker_experiences')
                ->with('files')
                ->where('workers.id', $userId)
                ->get()
        )->response()->setStatusCode(201);
    }
}
