companyModules()->where('type', '=', BusinessType::IMPORTER)->first(); return [ 'id' => $this->id, 'name' => $this->name, 'reference' => $this->reference, 'type' => (int) $this->type, 'business_type' => (int) $this->business_type, 'status' => (int) $this->status, 'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())), 'employee' => new UserResource($companyModule->employees()->first()), 'company_module' => new CompanyModuleResource($companyModule), 'last_order' => new OrderResource($companyModule ? $companyModule->orders()->orderBy('id', 'DESC')->first(): null), 'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first()), ]; } }