Files
opensem/app/Models/Shop/Customer.php
2023-09-12 23:00:36 +02:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Models\Shop;
use App\Notifications\ResetPassword;
use App\Notifications\VerifyEmail;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Yadahan\AuthenticationLog\AuthenticationLogable;
class Customer extends Authenticatable
{
use AuthenticationLogable, Notifiable, SoftDeletes;
protected $guarded = ['id'];
protected $table = 'shop_customers';
protected $hidden = ['password', 'remember_token'];
protected $casts = ['email_verified_at' => 'datetime'];
public function addresses(): HasMany
{
return $this->hasMany(CustomerAddress::class);
}
public function customer_deliveries(): HasMany
{
return $this->hasMany(CustomerDelivery::class);
}
public function deliveries(): BelongsToMany
{
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
}
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function orders(): HasMany
{
return $this->hasMany(Order::class);
}
public function sendEmailVerificationNotification()
{
if (config('boilerplate.auth.verify_email')) {
$this->notify(new VerifyEmail());
}
}
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
}
}