Skip to content

Instantly share code, notes, and snippets.

@jongravois
Created May 27, 2020 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jongravois/dfb8d4f3d9ffa069edb7a73737dfeba1 to your computer and use it in GitHub Desktop.
Save jongravois/dfb8d4f3d9ffa069edb7a73737dfeba1 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Livewire\Customers;
use App\Models\Company;
use App\Models\CompanyCustomerAgreement;
use Livewire\Component;
class CafRow extends Component
{
public $cafID;
public $cmpID;
public $ar_contact;
public $ar_email;
public $companyCode;
public $country;
public $deniedPartyChecked;
public $deniedPartyCleared;
public $legalName;
public $location;
public $phone;
public $reporter;
public $reporter_email;
public $statusID;
protected $listeners = [
'cafDeniedCheck' => '$refresh',
];
public function mount($id)
{
$this->cmpID = $id;
} // end function
public function render()
{
$cmp = Company::with('caf', 'contacts')->find($this->cmpID);
if($cmp) {
$this->cafID = $cmp->caf->id;
$this->ar_contact = ($cmp->contact ? $cmp->contacts->accounting_name : null);
$this->ar_email = ($cmp->contacts ? $cmp->contacts->accounting_email : null);
$this->companyCode = $cmp->company_code;
$this->country = $cmp->country;
$this->deniedPartyChecked = $cmp->denied_party_checked;
$this->deniedPartyCleared = $cmp->denied_party_cleared;
$this->legalName = strtoupper($cmp->legal_name);
$this->location = ucwords(strtolower($cmp->city)) . ' ' . $cmp->state;
$this->phone = $cmp->phone;
$this->reporter = $cmp->caf->reporter;
$this->reporter_email = $cmp->caf->reporter_email;
$this->statusID = $cmp->caf->status_id;
} // end if
return view('livewire.customers.caf-row');
} // end function
public function checkDenied($id)
{
$co = Company::with('caf')->find($id);
if($co) {
check_embargo($co);
$this->dispatchBrowserEvent('toast', [
'type' => 'success',
'msg' => 'Company Embargo Check complete'
]);
$this->emit('cafDeniedCheck');
} // end if
} // end function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment