<?php

namespace App\Services\Staff;

use App\Actions\Staff\CreateStaffAction;
use App\Actions\Staff\UpdateStaffAction;
use App\Contracts\StaffRepositoryContract;
use App\Models\User;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;

class StaffService
{
    public function __construct(
        private readonly StaffRepositoryContract $staff,
        private readonly CreateStaffAction $createStaff,
        private readonly UpdateStaffAction $updateStaff,
    ) {}

    public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator
    {
        return $this->staff->paginate($filters, $perPage);
    }

    public function paginateCustomers(array $filters = [], int $perPage = 15): LengthAwarePaginator
    {
        return $this->staff->paginateCustomers($filters, $perPage);
    }

    public function find(int $id): ?User
    {
        return $this->staff->find($id);
    }

    /**
     * @param  array<string, mixed>  $data
     */
    public function create(array $data): User
    {
        return $this->createStaff->execute($data);
    }

    /**
     * @param  array<string, mixed>  $data
     */
    public function update(User $user, array $data): User
    {
        return $this->updateStaff->execute($user, $data);
    }

    public function delete(User $user): bool
    {
        return $this->staff->delete($user);
    }
}
