CasperSecurity

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

<?php

namespace App\Http\Livewire\Hrms;

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

class OdApprovalLivewire 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 Od Type  has been saved successfully.";
    public $approvemsg = "The  Od Request has been approve successfully.";
    public $rejectmsg = "The  Od 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 = OdRequest::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 = OdRequest::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"){

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

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

       }

   }

    public function render()
    {
        $datatable=$this->read();
        return view('livewire.hrms.od-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