<?php

namespace App\Livewire\Admin;

use Livewire\Component;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use App\Models\OfficesDepartment;
use Livewire\WithPagination;
class OfficeDepartment extends Component
{
    use WithPagination;
    public $perPage = 5;
    public $search = null;
    public $department = null;
    protected $queryString = [
        'search'=>['except'=>'']
    ];
    public function updateSearch(){
        $this->resetPage();
    }
    protected $listeners = [
        'deleteOfficeDepartmentAction'
    ];
    public function deleteOfficeDepartment($id){
        $this->dispatch('deleteFaculty',['id'=>$id]);
       }
    
    public function render()
    {
        $officeDepartments = OfficesDepartment::with('officeDepartment')
        ->latest()
        ->search(trim($this->search))
        ->paginate($this->perPage);
        return view('livewire.admin.office-department', compact('officeDepartments'));
    }
    
}
