CasperSecurity

Current Path : /var/www/orientalss.com/app/Http/Livewire/Finance/
Upload File :
Current File : /var/www/orientalss.com/app/Http/Livewire/Finance/VendorLivewire.php

<?php

namespace App\Http\Livewire\Finance;

use Livewire\Component;
use App\Models\Vendor;
use App\Models\VendorType;
use Livewire\WithPagination;
use Livewire\WithFileUploads;

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

    public $search;
    public $perPage = 10;
    public $orderBy = 'id';
    public $orderAsc = '1';
    public $vendor_gst,$vendor_tele_phone,$vendor_address,$vendor_logo,$vendor_name,$vendor_code,$vendor_type,$vendor_fax, $vendor_mail
    ,$vendor_contact_person_telephone,$vendor_contact_person_mobile, $vendor_contact_person_mail,$inter_state,$status,$vendor_contact_person, $data;
    public $modelid;
    public $showmodal = false;

    public $successmsg = "The Vendor Type  has been saved successfully.";
    public $updatemsg = "The Vendor Type has been updated successfully.";
    public $deletemsg = "The Vendor Type data has been deleted successfully.";
    public $duplicateerrormsg = "Sorry !!! Vendor Type name has already exists in our database. Please Try Another Name";
    public $errormsg = "Sorry !!! Something went wrong. Please Try Again.";

    protected $listeners = ['delete'];

    public $rules = [
        'vendor_type' => 'required',
        'vendor_code' => 'required',
        'vendor_name' => 'required',
        'vendor_mail' => 'required|email',
        'vendor_tele_phone' => 'required',
        'vendor_address' => 'required',
    ];

   public $updatedrules = [
       'vendor_type' => 'required',
        'vendor_code' => 'required',
        'vendor_name' => 'required',
        'vendor_mail' => 'required|email',
        'vendor_tele_phone' => 'required',
        'vendor_address' => 'required',
       'inter_state'=> 'required',
    ];

    public $messages = [
        /*  'cash_type_id.required' => 'This field is required',*/
        'vendor_type.required' => 'This field is required',
        'vendor_code.required' => 'This field is required',
        'vendor_name.required' => 'This field is required',
        'vendor_mail.required' => 'This field is required',
        'vendor_mail.email' => 'The Vendor Mail must be a valid email address.',
        'vendor_tele_phone.required' => 'This field is required',
        'vendor_address.required' => 'This field is required',
        'inter_state.required' => 'This field is required',
    ];


    public function updatingSearch()
    {
        $this->resetPage();
    }

    /*public function showmodalclick()
    {
        $this->resetValidation();
        $this->showmodal = true;
    }*/
    public function showmodalclick(){

        $vendor=Vendor::all();
        if(sizeof($vendor)<10){
            $add="000".sizeof($vendor)+1;
        }
        elseif(sizeof($vendor)<100){
            $add="00".sizeof($vendor)+1;
        }
        elseif(sizeof($vendor)<1000){
            $add="0".sizeof($vendor)+1;
        }
        else{
            $add=sizeof($vendor+1);
        }
        $this->vendor_code="V".$add;

        $this->resetValidation();
        $this->cleanVar();
        $this->showmodal=true;

    }

    public function closemodalclick()
    {
        $this->resetValidation();
        $this->showmodal = false;
    }



    public function cleanVar()
    {
        $this->modelid = null;
        $this->vendor_type = null;
        $this->vendor_name = null;
        $this->vendor_logo = null;
        $this->vendor_address = null;
        $this->vendor_tele_phone = null;
        $this->vendor_gst = null;
        $this->vendor_fax = null;
        $this->vendor_mail = null;
        $this->vendor_contact_person_telephone = null;
        $this->vendor_contact_person_mobile = null;
        $this->vendor_contact_person_mail = null;
        $this->inter_state = 0;
        $this->status = null;
        $this->showmodal = false;
    }


    public function save(){
        $this->validate($this->rules,$this->messages);
        {
             $response = Vendor::create([
                'vendor_type' => $this->vendor_type,
                'vendor_code'=>$this->vendor_code,
                'vendor_name'=>$this->vendor_name,
                'vendor_logo'=>$this->vendor_logo->store('vendor_icon'),
                'vendor_address'=>$this->vendor_address,
                'vendor_tele_phone'=>$this->vendor_tele_phone,
                'vendor_gst'=>$this->vendor_gst,
                'vendor_fax'=>$this->vendor_fax,
                'vendor_mail'=>$this->vendor_mail,
                'vendor_contact_person_telephone'=>$this->vendor_contact_person_telephone,
                 'vendor_contact_person_mobile'=>$this->vendor_contact_person_mobile,
                 'vendor_contact_person_mail'=>$this->vendor_contact_person_mail,
                 'inter_state'=>$this->inter_state,
            ]);
            if ($response) {
                $this->cleanVar();
                $this->dispatchBrowserEvent('closeOffCanvas');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => $this->successmsg
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }
        }
    }
    public function updateclick($id){
        if($id != null){
        $this->modelid = $id;
        $vendor_data = Vendor::find($id);
        if($vendor_data != null){
            $this->vendor_type = $vendor_data['vendor_type'];
            $this->vendor_code = $vendor_data['vendor_code'];
            $this->vendor_name = $vendor_data['vendor_name'];
            $this->vendor_address = $vendor_data['vendor_address'];
            $this->vendor_tele_phone = $vendor_data['vendor_tele_phone'];
            $this->vendor_gst = $vendor_data['vendor_gst'];
            $this->vendor_fax = $vendor_data['vendor_fax'];
            $this->vendor_mail = $vendor_data['vendor_mail'];
            $this->vendor_contact_person_telephone = $vendor_data['vendor_contact_person_telephone'];
            $this->vendor_contact_person_mobile = $vendor_data['vendor_contact_person_mobile'];
            $this->vendor_contact_person_mail = $vendor_data['vendor_contact_person_mail'];
            $this->inter_state = $vendor_data['inter_state'];
            $this->status = $vendor_data['status'];
            $this->showmodal = true;
        }
        }
    }
   public function update()
    {
        $this->validate($this->updatedrules, $this->messages);
        $response =Vendor::find($this->modelid);
        if ($response) {
            $vendor_logo = $this->vendor_logo != null?$this->vendor_logo->store('vendor_icon'):$response['vendor_logo'];
            $response->update([
                'vendor_type' => $this->vendor_type,
                'vendor_code'=>$this->vendor_code,
                'vendor_name'=>$this->vendor_name,
                'vendor_logo'=>$vendor_logo,
                'vendor_address'=>$this->vendor_address,
                'vendor_tele_phone'=>$this->vendor_tele_phone,
                'vendor_gst'=>$this->vendor_gst,
                'vendor_fax'=>$this->vendor_fax,
                'vendor_mail'=>$this->vendor_mail,
                'vendor_contact_person_telephone'=>$this->vendor_contact_person_telephone,
                'vendor_contact_person_mobile'=>$this->vendor_contact_person_mobile,
                'vendor_contact_person_mail'=>$this->vendor_contact_person_mail,
                'inter_state'=>$this->inter_state,
                'status' => $this->status,
            ]);

            //dd($response);
            if ($response) {
                $this->cleanVar();
                $this->dispatchBrowserEvent('closeOffCanvas');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => $this->updatemsg
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }
        }
    }



    public function read()
    {
        $vendors = Vendor::search($this->search)->where('status',1)
            ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
            ->paginate($this->perPage);
        return $vendors;
    }

    public function render()
    {
        $datatable = $this->read();
        if (sizeof($datatable) > 0) {
            foreach ($datatable as $key => $data) {
                $vendor = VendorType::where('id', $data->vendor_type)->first();
                if ($vendor) {
                    $datatable[$key]['vendor_type_name'] = $vendor->vendor_type_name
                    ;
                } else {
                    $datatable[$key]['vendor_type_name'] = "NA";
                }
            }
        }

        $vendortype = VendorType::where('status', 1)->get();
        return view('livewire.finance.vendor-livewire',compact('datatable','vendortype'));
    }
}
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