CasperSecurity

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

<?php

namespace App\Http\Livewire\Tendermanagement;

use App\Models\TenderDocument;
use Illuminate\Support\Str;
use Livewire\Component;
use Livewire\WithFileUploads;
use Livewire\WithPagination;
use Illuminate\Support\Facades\Auth;

class TenderDocumentLivewire extends Component
{
    use WithPagination;
    use WithFileUploads;
    protected $paginationTheme = 'bootstrap';
    public $page_names="Manage Documents";
    public $page_name="Document";

    public $search;
    public $perPage=10;
    public $orderBy='id';
    public $orderAsc='1';
    public $document_name,$documement_path,$status;
   // public $completion_doc_flag=0;
    public $modelid;
    public $showmodal=false;
    public $showdoc=false;
    public $documentPath;


    public $rules=[
        'document_name'=>'required|max:255',
        /*'documement_path'=>'required|max:255'*/
    ];

    public $updatedrules=[
        'document_name'=>'required|max:255',
//        'documement_path'=>'required|max:255'
    ];

    public $messages=[
        'document_name.required'=>'This field is required',
        'document_name.max'=>'This field allows maximum 255 character',
        'documement_path.required'=>'This field is required',
        'documement_path.max'=>'This field allows maximum 255 character',
    ];

    protected $listeners = ['delete'];


    public function updateclick($id){
        $this->modelid=$id;

        // $this->resetValidation();
        $this->showmodal=true;
        $this->loadData($id);


    }

    public function loadData($id){
        $data=TenderDocument::find($id);
        if($data){
            $this->document_name=$data->document_name;
            $this->documement_path=$data->documement_path;
            $this->status=$data->status;
        }

        //dd($this->lat);
    }


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

    public function showmodalclick(){
        $this->resetValidation();
        $this->showmodal=true;
        //$this->dispatchBrowserEvent('livewire:load');
        $this->cleanVar();
    }

    public function showdocclick(){
        $this->resetValidation();
       /// $this->documentPath = $documentPath;
        $this->showdoc=true;
        $this->cleanVar();
        //$this->dispatchBrowserEvent('livewire:load');
    }
    public function closemodalclick(){
        $this->resetValidation();
        $this->showmodal=false;
        $this->cleanVar();

    }
    public function closedocclick(){
        $this->resetValidation();
        $this->showdoc=false;
        $this->cleanVar();

    }

    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->document_name=null;
        $this->documement_path=null;
        $this->status=null;
       // $this->showmodal=false;
    }

    public function modelData(){
        if ($this->documement_path && $this->documement_path instanceof \Illuminate\Http\UploadedFile) {
            $this->documement_path = $this->documement_path->store('requiredDocument');
        }
        if($this->modelid){
            $data=[
                'document_name'=>$this->document_name,
                'documement_path'=>$this->documement_path,
                'modified_by'=>Auth::user()->id,
                'status'=>$this->status,
            ];
        }
        else{
            $data=[
                'document_name'=>$this->document_name,
                'documement_path'=>$this->documement_path,
                'created_by'=>Auth::user()->id,
                'status'=>'1'
            ];
        }


        return $data;
    }

    public function save(){
        $this->validate($this->rules,$this->messages);
        $this->status=true;
        $response=TenderDocument::where('document_name',$this->document_name)->latest()->first();
        if($response){
            $this->dispatchBrowserEvent('showsuccessmsg',[
                'type'=>'error',
                'message'=>'Sorry !!! Document name has already exists in our database. Please Try Another Name'
            ]);
        }else{
            $response=TenderDocument::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 Document has been saved successfully'
                ]);
            }
        }

        //Str::kebab($this->dept_name)
    }

    public function update()
    {
       // dd($this->modelData());
        $this->validate($this->updatedrules,$this->messages);
        $response=TenderDocument::find($this->modelid);
        if($response){
            $response->update($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 Document has been updated successfully'
                ]);
            }
            else{
                $this->dispatchBrowserEvent('showsuccessmsg',[
                    'type'=>'error',
                    'message'=>'Sorry !!! Document name has already exists in our database. Please Try Another Name'
                ]);
            }
        }


    }
    public function delete(){
        $response=TenderDocument::find($this->modelid);
        if($response){
            $response->delete();
            $this->cleanVar();
            $this->dispatchBrowserEvent('showsuccessmsg',[
                'type'=>'success',
                'message'=>'The Document has been deleted successfully'
            ]);
        }
    }
    public function read(){
        $tender_document=TenderDocument::search($this->search)->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')->paginate($this->perPage);
        return $tender_document;
    }

    public function render()
    {
        $tenderdocuments=$this->read();
        return view('livewire.tendermanagement.tender-document-livewire',compact('tenderdocuments'));
    }
}
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