<?php

namespace App\Auth;

use App\Models\User;
use App\Services\DummyDataService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\UserProvider;

class DummyUserProvider implements UserProvider
{
    /**
     * Retrieve a user by their unique identifier.
     */
    public function retrieveById($identifier)
    {
        $allSiswa = DummyDataService::getAllSiswa();
        $userArray = collect($allSiswa)->firstWhere('id', $identifier);

        if ($userArray) {
            $userModel = new User();
            $userArray['name'] = $userArray['nama_lengkap'];
            $userModel->forceFill($userArray);
            return $userModel;
        }

        return null;
    }

    /**
     * Rehash the user's password if required.
     */
    public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
    {
    }

    public function retrieveByToken($identifier, $token) { return null; }
    public function updateRememberToken(Authenticatable $user, $token) { }
    public function retrieveByCredentials(array $credentials) { return null; }
    public function validateCredentials(Authenticatable $user, array $credentials) { return false; }
}