Created
May 27, 2020 22:14
-
-
Save jongravois/aaab726a8bbf91e97ceb94fdadd2b4f9 to your computer and use it in GitHub Desktop.
This file contains 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\Customers; | |
use App\Http\Resources\CustomerAgreementResource; | |
use App\Models\Company; | |
use App\Models\CompanyCustomerAgreement; | |
use Illuminate\Support\Facades\DB; | |
use Livewire\Component; | |
class CustomerPortal extends Component | |
{ | |
public $search = ''; | |
public $statusIndicator; | |
public $agreements; | |
public $invited; | |
public $initiated; | |
public $submitted; | |
public $verified; | |
public $approved; | |
public $processed; | |
public $completed; | |
protected $listeners = [ | |
'cafDeniedCheck' => 'render', | |
'cafDeleted' => '$refresh', | |
'cafUploaded' => 'cafUploaded', | |
'cafProcessed' => 'cafProcessed' | |
]; | |
public function mount($status=null) | |
{ | |
if($status) { | |
$this->statusIndicator = $status; | |
} else { | |
$this->statusIndicator = 3; | |
} // end if | |
} // end function | |
public function render() | |
{ | |
$query = Company::has('caf') | |
->with( 'caf:id,company_id,status_id,reporter,reporter_email', 'contacts:id,company_id,accounting_name,accounting_email' ) | |
->select('id', 'company_code', 'legal_name', 'city', 'state', 'phone', 'country', 'denied_party_checked', 'denied_party_cleared', 'last_denied_party_check'); | |
if($this->search) { | |
$term = "%{$this->search}%"; | |
$query->where('legal_name','like', $term) | |
->orwhere('company_code','like', $term); | |
$this->agreements = $query->get(); | |
} else { | |
$this->agreements = $query->get()->where('caf.status_id', $this->statusIndicator); | |
} // end if | |
$this->invited = CompanyCustomerAgreement::whereStatusId(1)->get()->count(); | |
$this->initiated = CompanyCustomerAgreement::whereStatusId(2)->get()->count(); | |
$this->submitted = CompanyCustomerAgreement::whereStatusId(3)->get()->count(); | |
$this->verified = CompanyCustomerAgreement::whereStatusId(4)->get()->count(); | |
$this->approved = CompanyCustomerAgreement::whereStatusId(5)->get()->count(); | |
$this->processed = CompanyCustomerAgreement::whereStatusId(6)->get()->count(); | |
$this->completed = CompanyCustomerAgreement::whereStatusId(7)->get()->count(); | |
return view('livewire.customers.customer-portal'); | |
} | |
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 | |
public function tabber($tab) | |
{ | |
$this->statusIndicator = $tab; | |
} // end function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment