28 lines
1.4 KiB
PHP
28 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\UsesStringIds;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class CustomerProfile extends Model
|
|
{
|
|
use UsesStringIds;
|
|
|
|
public const CREATED_AT = 'createdAt';
|
|
public const UPDATED_AT = 'updatedAt';
|
|
protected $table = 'CustomerProfile';
|
|
protected $fillable = ['businessId', 'userId', 'firstName', 'lastName', 'email', 'phone', 'isGuest', 'preferredBarberId'];
|
|
protected function casts(): array { return ['isGuest' => 'boolean']; }
|
|
public function business(): BelongsTo { return $this->belongsTo(Business::class, 'businessId'); }
|
|
public function user(): BelongsTo { return $this->belongsTo(User::class, 'userId'); }
|
|
public function preferredBarber(): BelongsTo { return $this->belongsTo(StaffProfile::class, 'preferredBarberId'); }
|
|
public function appointments(): HasMany { return $this->hasMany(Appointment::class, 'customerId'); }
|
|
public function loyaltyAccounts(): HasMany { return $this->hasMany(LoyaltyAccount::class, 'customerId'); }
|
|
public function notes(): HasMany { return $this->hasMany(CustomerNote::class, 'customerId'); }
|
|
public function receivedNotifications(): HasMany { return $this->hasMany(Notification::class, 'recipientCustomerId'); }
|
|
public function pushSubscriptions(): HasMany { return $this->hasMany(PushSubscription::class, 'customerId'); }
|
|
}
|