<?php

namespace App\Http\Controllers\admin;

use App\Http\Controllers\Controller;
use App\Services\EmployeeServices;
use App\Traits\GetModelsPaginated;
use Illuminate\Http\Request;

class EmployeeController extends Controller
{
    protected $employeeServices;
    use GetModelsPaginated;
    public function __construct(EmployeeServices $employeeServices      )
    {
        $this->employeeServices = $employeeServices;
    }
    public function index(Request $request)
    {
        return view('admin.employees.index');
    }
    
    public function employeePaginatedJson(Request $request)
    {
        return $this->paginateFromService(
            $request,
            fn (int $page, int $length, ?string $searchValue, ?string $status) =>
                $this->employeeServices->getEmployeeData($page, $length, $searchValue, $status),
            [
                'model' => 'employee',
                'fields' => ['id', 'position', 'hire_date', 'salary', 'work_schedule', 'specialty', 'people_id', 'created_at'],
            ]
        );
    
    }
}
