Files
opensem/app/Models/Shop/Customer.php
Ludovic CANDELLIER 06cfb92757 [WIP] Order process
2022-07-03 22:38:08 +02:00

67 lines
1.7 KiB
PHP

<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Yadahan\AuthenticationLog\AuthenticationLogable;
use App\Notifications\NewUser;
use App\Notifications\ResetPassword;
use App\Notifications\VerifyEmail;
class Customer extends Authenticatable
{
use AuthenticationLogable, Notifiable, SoftDeletes;
protected $guarded = ['id'];
protected $table = 'shop_customers';
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'settings', 'last_login'];
protected $hidden = ['password', 'remember_token'];
protected $casts = ['email_verified_at' => 'datetime'];
public function addresses()
{
return $this->hasMany(CustomerAddress::class);
}
public function invoices()
{
return $this->hasMany(Invoice::class);
}
public function customer_deliveries()
{
return $this->hasMany(CustomerDelivery::class);
}
public function deliveries()
{
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
}
public function deliveries2()
{
return $this->hasManyThrough(Delivery::class, CustomerDelivery::class);
}
public function orders()
{
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));
}
}