belongsTo('App\Models\Common\Contact')->withDefault(['name' => trans('general.na'), 'rate' => 0]); } public function scopeType(Builder $query, array $types): Builder { if (empty($types)) { return $query; } return $query->whereIn($this->qualifyColumn('type'), (array) $types); } public function scopeVendor(Builder $query): Builder { return $query->whereIn($this->qualifyColumn('type'), (array) $this->getVendorTypes()); } public function scopeCustomer(Builder $query): Builder { return $query->whereIn($this->qualifyColumn('type'), (array) $this->getCustomerTypes()); } public function scopeEmployee(Builder $query): Builder { return $query->whereIn($this->qualifyColumn('type'), (array) $this->getEmployeeTypes()); } public function scopeEmail(Builder $query, $email): Builder { return $query->where('email', '=', $email); } public function getInitialsAttribute($value) { return Str::getInitials($this->name); } }