- Implement EmailNotifier for sending batch and test notifications via email. - Implement TelegramNotifier for sending batch and test notifications via Telegram. - Implement WahaNotifier for sending batch and test notifications via WhatsApp using WAHA API. - Create migration for client_categories table and update clients table to include category_id. - Create migration for notification_settings table to manage notification configurations. - Add ClientCategorySeeder to populate default client categories. - Create manifest.json for PWA support. - Implement service worker (sw.js) for caching static assets and offline support. - Add edit event view for modifying scheduled events. - Create search results view for displaying search queries. - Develop notification settings view for configuring notification channels and triggers.
78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\ClientStatus;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Client extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name', 'email', 'phone', 'company',
|
|
'ig_handle', 'tiktok_handle', 'youtube_handle',
|
|
'address_line1', 'address_line2', 'city', 'state', 'postal_code', 'country',
|
|
'status', 'category_id', 'notes', 'avatar',
|
|
];
|
|
|
|
protected $casts = [
|
|
'status' => ClientStatus::class,
|
|
];
|
|
|
|
// ── Relationships ────────────────────────────────────────────
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ClientCategory::class, 'category_id');
|
|
}
|
|
|
|
public function events(): HasMany
|
|
{
|
|
return $this->hasMany(Event::class);
|
|
}
|
|
|
|
public function invoices(): HasMany
|
|
{
|
|
return $this->hasMany(Invoice::class);
|
|
}
|
|
|
|
public function contentBriefs(): HasMany
|
|
{
|
|
return $this->hasMany(ContentBrief::class);
|
|
}
|
|
|
|
public function mediaFiles(): HasMany
|
|
{
|
|
return $this->hasMany(MediaFile::class);
|
|
}
|
|
|
|
// ── Accessors ────────────────────────────────────────────────
|
|
|
|
public function getFullAddressAttribute(): string
|
|
{
|
|
return collect([
|
|
$this->address_line1,
|
|
$this->address_line2,
|
|
$this->city,
|
|
$this->state,
|
|
$this->postal_code,
|
|
$this->country,
|
|
])->filter()->implode(', ');
|
|
}
|
|
|
|
public function getInitialsAttribute(): string
|
|
{
|
|
$words = explode(' ', $this->name);
|
|
return strtoupper(
|
|
collect($words)->take(2)->map(fn ($w) => $w[0] ?? '')->implode('')
|
|
);
|
|
}
|
|
}
|