Skip to content

Instantly share code, notes, and snippets.

@jongravois
Created January 19, 2021 20:31
Show Gist options
  • Save jongravois/a0f4c38b0051d08abe5a70be1d677df2 to your computer and use it in GitHub Desktop.
Save jongravois/a0f4c38b0051d08abe5a70be1d677df2 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Livewire\Customers;
use App\Models\Company;
use Livewire\Component;
class CompanyRow extends Component
{
public Company $company;
public $duncan;
public $henderson;
public $hudson;
public $muller;
public $walker;
public function mount(): void
{
$this->duncan = false;
$this->henderson = false;
$this->hudson = false;
$this->muller = false;
$this->walker = false;
if($this->company->user_id === 88) {
$this->duncan = true;
} else {
$this->duncan = false;
} // end if
if($this->company->user_id === 225) {
$this->henderson = true;
} else {
$this->henderson = false;
} // end if
if($this->company->user_id === 232) {
$this->hudson = true;
} else {
$this->hudson = false;
} // end if
if($this->company->user_id === 174) {
$this->muller = true;
} else {
$this->muller = false;
} // end if
if($this->company->user_id === 199) {
$this->walker = true;
} else {
$this->walker = false;
} // end if
} // end function
public function render()
{
return view('livewire.customers.company-row');
} // end function
public function updatedDuncan(): void
{
if($this->duncan) {
$this->company->user_id = 88;
$this->company->save();
} else {
$this->company->user_id = null;
$this->company->save();
} // end if
} // end function
public function updatedHenderson(): void
{
if($this->henderson) {
$this->company->user_id = 225;
$this->company->save();
} else {
$this->company->user_id = null;
$this->company->save();
} // end if
} // end function
public function updatedHudson(): void
{
if($this->hudson) {
$this->company->user_id = 232;
$this->company->save();
} else {
$this->company->user_id = null;
$this->company->save();
} // end if
} // end function
public function updatedMuller(): void
{
if($this->muller) {
$this->company->user_id = 174;
$this->company->save();
} else {
$this->company->user_id = null;
$this->company->save();
} // end if
} // end function
public function updatedWalker(): void
{
if($this->walker) {
$this->company->user_id = 199;
$this->company->save();
} else {
$this->company->user_id = null;
$this->company->save();
} // end if
} // end function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment