CasperSecurity

Current Path : /var/www/orientalss.com/app/Http/Livewire/Hrms/
Upload File :
Current File : /var/www/orientalss.com/app/Http/Livewire/Hrms/LeaveApprovalLivewire.php

<?php

namespace App\Http\Livewire\Hrms;

use App\Models\EmployeeRegistration;
use App\Models\LeaveRequest;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Livewire\WithPagination;

class LeaveApprovalLivewire extends Component
{
    use WithPagination;
    protected $paginationTheme = 'bootstrap';

    public $search;
    public $perPage = 10;
    public $orderBy = 'id';
    public $orderAsc = '1';
    public $modelid;
    public $showmodal = false;

    public $successmsg = "The Leave Type  has been saved successfully.";
    public $approvemsg = "The  Leave Request has been approve successfully.";
    public $rejectmsg = "The  Leave Type data has been rejetct successfully.";
    public $errormsg = "Sorry !!! Something went wrong. Please Try Again.";

    protected $listeners = ['reject'];

    public function closemodalclick()
    {
        $this->resetValidation();

    }

    public function cleanVar()
    {
        $this->modelid = null;
        $this->status = null;
        $this->showmodal = false;
    }

    public function approveclick($id)
    {
        $response = LeaveRequest::find($id);
        if ($response) {
            if($response->manager_approval_status==1){
                $response->update(['manager_approval_status'=>2]);
                $this->dispatchBrowserEvent('closeOffCanvas');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' =>'Approved By Manager.Waiting for HR approval'
                ]);
            }
            elseif($response->manager_approval_status==2 && $response->hr_approval_status==1){
                $response->update(['hr_approval_status'=>2,
                    'status'=>2
                ]);
                $this->dispatchBrowserEvent('closeOffCanvas');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => 'Approved By HR'
                ]);
            }



        } else {
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'error',
                'message' => $this->errormsg
            ]);
        }

    }

    public function rejectclick($id)
    {
        $response = LeaveRequest::find($id);
        if ($response) {
            if ($response) {
                $response->update(['status'=>0]);
                $this->cleanVar();
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => $this->rejectmsg
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }
        }
    }
    public function read()
    {
        if(Auth::user()->name=="superadmin" || Auth::user()->name=="admin"){

            $leave_requests = LeaveRequest::search($this->search)
                ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
                ->paginate($this->perPage);
            return $leave_requests;
        }
        else{

            $empdet=EmployeeRegistration::where('employee_id',Auth::user()->employee_id)->first();
            if($empdet){
                $leave_requests = LeaveRequest::where('manager_id',$empdet->id)->orWhere('hr_id',$empdet->id)
                    ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
                    ->paginate($this->perPage);
                return $leave_requests;
            }
            else{
                return [];
            }

        }

    }

    public function render()
    {
        $datatable=$this->read();
        return view('livewire.hrms.leave-approval-livewire',compact('datatable'));
    }
}
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY