Created
February 14, 2021 19:49
-
-
Save jongravois/d0f5f9aaf9c53c48dbb4e94f6042c94a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire\Levo; | |
use App\Models\CompanyType; | |
use App\Models\ReportsSalesTeam; | |
use Livewire\Component; | |
class AdminSales extends Component | |
{ | |
public $sale; | |
public $showEditor = false; | |
protected $rules = [ | |
'sale.title' => 'nullable', | |
'sale.salesperson_code' => 'nullable' | |
]; | |
public function mount(): void | |
{ | |
$this->sale = ReportsSalesTeam::make(); | |
} // end function | |
public function render() | |
{ | |
return view('livewire.levo.admin-sales', [ | |
'sales' => ReportsSalesTeam::orderBy('sort_order')->get() | |
]); | |
} // end function | |
public function createSale(): void | |
{ | |
$this->sale = ReportsSalesTeam::make(); | |
$this->showEditor = true; | |
} // end function | |
public function deleteSale($id): void | |
{ | |
ReportsSalesTeam::find($id)->delete(); | |
$this->dispatchBrowserEvent('toast', [ | |
'type' => 'success', | |
'msg' => 'This has been deleted' | |
]); | |
} // end function | |
public function editSale($id): void | |
{ | |
$this->sale = ReportsSalesTeam::whereId($id)->first(); | |
$this->showSalesEditor = true; | |
} // end function | |
public function persistSale(): void | |
{ | |
$this->sale->save(); | |
$this->sale = ReportsSalesTeam::make(); | |
$this->showEditor = false; | |
} // end function | |
public function updateOrder($groupsStructure): void | |
{ | |
foreach($groupsStructure as $groupitem) { | |
ReportsSalesTeam::whereId($groupitem['value'])->update([ | |
'sort_order' => $groupitem['order'] | |
]); | |
} // end foreach | |
} // end function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment