/home/techb158/immovalet.com/platform/plugins/ecommerce/src/Models
Edit: /home/techb158/immovalet.com/platform/plugins/ecommerce/src/Models/Customer.php (3169B)
notify(new ResetPasswordNotification($token));
}
/**
* @return string
*/
public function getAvatarUrlAttribute()
{
if ($this->avatar) {
return RvMedia::getImageUrl($this->avatar, 'thumb');
}
try {
return (new Avatar)->create($this->name)->toBase64();
} catch (Exception $exception) {
return RvMedia::getDefaultImage();
}
}
/**
* @return HasMany
*/
public function orders()
{
return $this->hasMany(Order::class, 'user_id', 'id');
}
/**
* @return HasMany
*/
public function addresses()
{
return $this->hasMany(Address::class, 'customer_id', 'id');
}
/**
* @return BelongsToMany
*/
public function discounts()
{
return $this->belongsToMany(Discount::class, 'ec_discount_customers', 'customer_id', 'id');
}
/**
* @return BelongsToMany
*/
public function wishlist(): HasMany
{
return $this->hasMany(Wishlist::class, 'customer_id');
}
protected static function boot()
{
parent::boot();
self::deleting(function (Customer $customer) {
$customer->discounts()->detach();
Review::where('customer_id', $customer->id)->delete();
Wishlist::where('customer_id', $customer->id)->delete();
});
}
/**
* @param string $key
* @return mixed
*/
public function __get($key)
{
if (class_exists('MacroableModels')) {
$method = 'get' . Str::studly($key) . 'Attribute';
if (MacroableModels::modelHasMacro(get_class($this), $method)) {
return call_user_func([$this, $method]);
}
}
return parent::__get($key);
}
/**
* @return HasMany
*/
public function reviews(): HasMany
{
return $this->hasMany(Review::class, 'customer_id');
}
}