/** * Fill the company_name attribute from the company_id. * * If this company name is already populated, then this does nothing. * * @return Contact provides a fluent interface. */ public function fillCompanyName() { if (!empty($this->company_name)) { return $this; } if (empty($this->company_id)) { return $this; } $company = Company::find($this->company_id); $this->company_name = $company->company_name; return $this; }