client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ 'home_phone' => $contact->client->phone, 'custom_identifier' => $contact->client->client_hash, 'name' => $contact->client->name, 'id' => null, ])->all(); $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields)); } private $fields = [ 'name', 'email', 'home_phone', 'phone', 'custom_identifier', 'customer_type' , 'id' ]; private $defaults = [ 'customer_type' => "Business", 'custom_identifier' => null, 'customer_id' => null ]; public function render() { return render('gateways.rotessa.components.contact', $this->attributes->getAttributes() + $this->defaults); } }