CasperSecurity

Current Path : /var/www/orientalss.com/app/Http/Livewire/Tendermanagement/
Upload File :
Current File : /var/www/orientalss.com/app/Http/Livewire/Tendermanagement/ClientLivewire.php

<?php

namespace App\Http\Livewire\Tendermanagement;

use App\Models\Client;
use App\Models\ClientCategory;
use App\Models\SettingsCountry;
use App\Models\SettingsState;
use Livewire\Component;
use Livewire\WithFileUploads;
use Livewire\WithPagination;

class ClientLivewire extends Component
{
    use WithFileUploads;
    use WithPagination;
    protected $paginationTheme = 'bootstrap';
    public $page_names = "Manage Clients";
    public $page_name = "Client";


    public $search;
    public $perPage = 10;
    public $orderBy = 'id';
    public $orderAsc = '1';
    public $client_name, $client_category_id, $client_address, $contact_name, $contact_mobile, $contact_mail, $client_country, $client_state, $billing_address, $fax, $cin_no, $pan_no, $gst_no, $logo, $currency, $status;
    public $states = [];

    public $work_location,$multi_locations,$location_type,$other_location;


    public $modelid;
    public $showmodal = false;
    public $multi_area = false;

    protected $listeners = ['delete'];

    public $rules = [
        'client_name' => 'required|max:255',
        'client_category_id' => 'required',
        'client_country' => 'required',
        'client_state' => 'required',
        'client_address' => 'required',
        'billing_address' => 'required',
        // 'gst_no' => 'required',
        // 'contact_name' => 'required|max:255',
        // 'contact_mobile' => 'required|digits:10',
        // 'contact_mail' => 'required|email|max:255',
    ];

    public $messages = [
        'client_name.required' => 'This field is required',
        'client_name.max' => 'This field allows maximum 255 character',
        'client_category_id.required' => 'This field is required',
        'client_country.required' => 'This field is required',
        'client_state.required' => 'This field is required',
        'client_address.required' => 'This field is required',
        'billing_address.required' => 'This field is required',
        // 'contact_name.required' => 'This field is required',
        // 'contact_name.max' => 'This field allows maximum 255 character',
        // 'contact_mobile.required' => 'This field is required',
        // 'contact_mobile.max' => 'This field allows maximum 255 character',
        // 'contact_mail.required' => 'This field is required',
        // 'gst_no.required' => 'This field is required',
        // 'contact_mail.email' => 'This field must be an email',

    ];

    public function updateclick($id)
    {
        $this->modelid = $id;
        $this->showmodal = true;
        $this->loadData($id);
    }


    public function loadData($id)
    {
        $data = Client::find($id);

        if ($data) {
            $this->client_name = $data->client_name;
            $this->client_category_id = $data->client_category_id;
            $this->client_country = $data->client_country;
            $this->client_state = $data->client_state;
            $this->client_address = $data->client_address;
            $this->billing_address = $data->billing_address;
            $this->contact_name = $data->contact_name;
            $this->contact_mobile = $data->contact_mobile;
            $this->contact_mail = $data->contact_mail;
            $this->fax = $data->fax;
            $this->pan_no = $data->pan_no;
            $this->cin_no = $data->cin_no;
            $this->gst_no = $data->gst_no;
            $this->status = $data->status;
        }
        return $data;
    }

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

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

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

    }

    public function deleteclick($id)
    {
        $this->modelid = $id;
        $this->dispatchBrowserEvent('confirmdelete', [
            'message' => 'Are you sure want to delete this data ?',
            'funcname' => 'delete'
        ]);
    }

    public function cleanVar()
    {
        $this->modelid = null;
        $this->client_name = null;
        $this->client_category_id = null;
        $this->client_address = null;
        $this->contact_name = null;
        $this->contact_mobile = null;
        $this->contact_mail = null;
        $this->fax = null;
        $this->cin_no = null;
        $this->gst_no = null;
        $this->pan_no = null;
        $this->logo = null;
        $this->client_state = null;
        $this->client_country = null;
        $this->billing_address = null;
    }

    public function updatedClientCountry($val)
    {
        if ($val) {
            $this->states = SettingsState::select('id', 'state_name')->where('settings_country_id', $val)->where('status', 1)->get();
        }
    }

    public function updatedLocationType($value){
       // dd('');
        if($value==1){
            $this->multi_area=true;
        }

    }

    public function modelData()
    {
        $created_by = $modified_by = null;
        if ($this->modelid) {
            $modified_by = auth()->id();
        } else {
            $created_by = auth()->id();
        }

        if ($this->logo && $this->logo instanceof \Illuminate\Http\UploadedFile) {
            $this->logo = $this->logo->store('client_logo');
        }

        $data = [
            'client_name' => $this->client_name,
            'client_category_id' => $this->client_category_id,
            'client_address' => $this->client_address,
            'contact_name' => $this->contact_name,
            'contact_mobile' => $this->contact_mobile,
            'contact_mail' => $this->contact_mail,
            'client_country' => $this->client_country,
            'client_state' => $this->client_state,
            'billing_address' => $this->billing_address,
            'fax' => $this->fax,
            'cin_no' => $this->cin_no,
            'pan_no' => $this->pan_no,
            'gst_no' => $this->gst_no,
            'logo' => $this->logo ? $this->logo : null,
            'created_by' => $created_by,
            'modified_by' => $modified_by,
            'status' => $this->modelid ? $this->status : '1',
        ];
        return $data;
    }

    public function save()
    {
        $res = $this->validate($this->rules, $this->messages);
        if ($res) {
            $response = Client::create($this->modelData());
            if ($response) {
                $this->cleanVar();
                $this->dispatchBrowserEvent('closeOffCanvas');
                //emotify('success', 'The Department data has been saved successfully');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => 'The  data has been saved successfully'
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => 'Sorry !!!Something went wrong'
                ]);
            }
        } else {

            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'error',
                'message' => 'Sorry !!!Data Invalid'
            ]);
        }

    }


    public function update()
    {
        $this->validate($this->rules, $this->messages);
        $response = Client::find($this->modelid);
        if ($response) {
            $response->update($this->modelData());
            if ($response) {
                $this->cleanVar();
                $this->dispatchBrowserEvent('closeOffCanvas');
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => 'The  data has been updated successfully'
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => 'Sorry !!! Something went Wrong'
                ]);
            }
        }


    }

    public function delete()
    {
        $response = Client::find($this->modelid);
        if ($response) {
            $response->delete();
            $this->cleanVar();
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'success',
                'message' => 'The  data has been deleted successfully'
            ]);
        }
    }

    public function read()
    {
        $clientdetail = Client::search($this->search)->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')->paginate($this->perPage);
        return $clientdetail;
    }

    public function render()
    {
        $clientdetails = $this->read();
        $clientcategories = ClientCategory::where('status', 1)->get();
        $countrys = SettingsCountry::select('id', 'country_name')->where('status', 1)->get();
        return view('livewire.tendermanagement.client-livewire', compact('clientdetails', 'clientcategories', 'countrys'));
    }
}
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