���Root Mod By V1rus_Alfa
User / IP
:
216.73.217.78
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
repositories
/
cutunix
/
app
/
Livewire
/
Admin
/
Pages
/
Analyze
/
Units
/
Viewing: Add.php
<?php namespace App\Livewire\Admin\Pages\Analyze\Units; use App\Models\Unit; use Livewire\Component; use App\Models\AnalyzeMaterial; use Masmerise\Toaster\Toastable; use Illuminate\Filesystem\Filesystem; use function App\Helpers\imageHelperApi; use App\Helpers\HelperClass\GeneralUseV2; class Add extends Component { use Toastable; public $num=4; public $num_formula=1; public $materials ; protected $listeners = ['refreshData' => '$refresh','selectData' => 'handelSelectData' ]; public function mount() { $this->authorize('analyze.units.add'); $this->materials=AnalyzeMaterial::latest()->get(); $this->handelChangeType(3); } public $form=[ 'title'=>'', 'title_en'=>'', 'category'=>'0', 'image_2D'=>'', 'image_3D'=>'', 'image_2D_en'=>'', 'sort' => '', 'variable'=>[ 0 => [ 'label'=>'عرض', 'label_en'=>'Width', 'key'=>'x', 'num_option'=>1, 'type'=>'1', 'default'=>'', 'options'=>[ 0 => [ 'title'=>'', 'value'=>'', ] ] ], 1 => [ 'label'=>'عمق', 'label_en'=>'Depth', 'key'=>'y', 'num_option'=>1, 'type'=>'1', 'default'=>'', 'options'=>[ 0 => [ 'title'=>'', 'value'=>'', ] ] ], 2 => [ 'label'=>'ارتفاع', 'label_en'=>'Height', 'key'=>'z', 'num_option'=>1, 'type'=>'1', 'default'=>'', 'options'=>[ 0 => [ 'title'=>'', 'value'=>'', ] ] ], 3 => [ 'label'=>'رنگ درب', 'label_en'=>'Door color', 'key'=>'c', 'num_option'=>1, 'type'=>'3', 'default'=>'0', 'options'=>[ 0 => [ 'title'=>'', 'value'=>'', ] ] ] ], 'formula'=>[ 0 => [ 'length'=>'', 'width'=>'', 'var_1'=>'', 'var_2'=>'', 'count'=>'', 'label'=>'', 'label_en'=>'', 'material'=>'', 'material_key'=>'', 'length_one'=>'', 'length_two'=>'', 'width_one'=>'', 'width_two'=>'', 'image'=>'', 'sort'=> null, ] ] ]; public function handelSelectData($data,$type) { if($type == 'image_2D' || $type == 'image_3D'){ $this->form[$type]=$data; }else{ $this->form['formula'][$type]['image']=$data; } } public function handelFormula($type=null) { if($type == 'increment'){ $this->num_formula=$this->num_formula+1; array_push($this->form['formula'],[ 'length'=>'', 'width'=>'', 'var_1'=>'', 'var_2'=>'', 'count'=>'', 'label'=>'', 'label_en'=>'', 'material'=>'', 'material_key'=>'', 'length_one'=>'', 'length_two'=>'', 'width_one'=>'', 'width_two'=>'', 'image'=>'', 'sort'=> null, ]); $this->dispatch('refreshData' ); }elseif(1 < $this->num_formula){ $this->num_formula=$this->num_formula-1; unset($this->form['formula'][$this->num_formula]); } } public function handelVariable($type=null) { if($type == 'increment'){ $this->num=$this->num+1; array_push($this->form['variable'],[ 'label'=>'', 'label_en'=>'', 'key'=>'', 'num_option'=>1, 'type'=>'1', 'default'=>'', 'options'=>[ 0 => [ 'title'=>'', 'value'=>'', ] ] ]); $this->dispatch('refreshData' ); }elseif(1 < $this->num){ $this->num=$this->num-1; unset($this->form['variable'][$this->num]); } } public function handelOption($type=null,$num=null ) { if($type == 'increment'){ $this->form['variable'][$num]['num_option']=$this->form['variable'][$num]['num_option']+1; array_push($this->form['variable'][$num]['options'] ,[ 'title'=>'', 'value'=>'', ]); }elseif(1 < $this->form['variable'][$num]['num_option']){ $this->form['variable'][$num]['num_option']=$this->form['variable'][$num]['num_option']-1; array_splice($this->form['variable'][$num]['options'], $this->form['variable'][$num]['num_option'], 1); } } public function handelChangeType($i=null ) { if($this->form['variable'][$i]['type'] == '3'){ $this->form['variable'][$i]['num_option']=$this->form['variable'][$i]['num_option']+1; $this->form['variable'][$i]['options']=[]; foreach ($this->materials as $key=>$row) { array_push($this->form['variable'][$i]['options'] ,[ 'title'=>$row->title, 'value'=>$row->id, ]); } }else if($this->form['variable'][$i]['type'] == '2'){ $this->form['variable'][$i]['num_option']=1; $this->form['variable'][$i]['options']=[ 0 => [ 'title'=>'', 'value'=>'', ]]; } } public function removeVariableRow($i=null ) { array_splice($this->form['variable'] , $i, 1); $this->num=$this->num-1; } public function removeVariableOptionsRow($i=null,$key=null) { array_splice($this->form['variable'][$i]['options'] , $key, 1); } public function validate_data() { $error=null; if(!$this->form['title']){ $error='true'; $this->error(' فیلد نام یونیت اجباری می باشد '); return $error; } if(!$this->form['title_en']){ $error='true'; $this->error(' فیلد نام یونیت انگلیسی اجباری می باشد '); return $error; } if(!$this->form['category']){ $error='true'; $this->error(' فیلد دسته بندی اجباری می باشد '); return $error; } foreach ($this->form['variable'] as $key=>$obj) { if(!$obj['label'] ){ $error='true'; $this->error(' فیلد لیبل در متغیر '.$key.' اجباری می باشد '); return $error; } if(!$obj['label_en'] ){ $error='true'; $this->error(' فیلد لیبل انگلیسی در متغیر '.$key.' اجباری می باشد '); return $error; } if(!$obj['key'] ){ $error='true'; $this->error(' فیلد key در متغیر '.$key.' اجباری می باشد '); return $error; } } foreach ($this->form['formula'] as $key=>$obj) { if(!$obj['length'] ){ $error='true'; $this->error(' فیلد طول در فرمول '.$key.' اجباری می باشد '); return $error; } if(!$obj['width'] ){ $error='true'; $this->error(' فیلد عرض در فرمول '.$key.' اجباری می باشد '); return $error; } if(!$obj['count'] ){ $error='true'; $this->error(' فیلد تعداد در فرمول '.$key.' اجباری می باشد '); return $error; } if(!$obj['label'] ){ $error='true'; $this->error(' فیلد لیبل در فرمول '.$key.' اجباری می باشد '); return $error; } if(!$obj['label_en'] ){ $error='true'; $this->error(' فیلد لیبل انگلیسی در فرمول '.$key.' اجباری می باشد '); return $error; } if(!$obj['material'] || $obj['material'] == '0' ){ $error='true'; $this->error(' فیلد متریال در فرمول '.$key.' اجباری می باشد '); return $error; } } return $error; } public function submit(Filesystem $filesystem) { //validation $validate= $this->validate_data(); if($validate){ return $validate; } $unit=Unit::create([ 'title'=>$this->form['title'], 'sort' => $this->form['sort'], 'title_en'=>$this->form['title_en'], 'category'=>$this->form['category'], 'count_formula'=>$this->num_formula, ]); if($this->form['image_2D']){ imageHelperApi($this->form['image_2D'],$filesystem,'',300,300,'',true,$unit->id,'Unit_2D'); } if($this->form['image_3D']){ imageHelperApi($this->form['image_3D'],$filesystem,'',300,300,'',true,$unit->id,'Unit_3D'); } if($this->form['image_2D_en']){ imageHelperApi($this->form['image_2D_en'],$filesystem,'',300,300,'',true,$unit->id,'Unit_2D_En'); } GeneralUseV2::create_formula($filesystem,$this->form,$unit->id); return \Redirect::to('/admin/analyze/units')->success('عملیات با موفقیت انجام شد'); } public function render() { return view('livewire.admin.pages.analyze.units.add' )->layoutData(['page_name' => 'analyze_units_index']); } }
Coded With 💗 by
0x6ick Mod By V1rus_Alfa