initial commit
This commit is contained in:
67
app/Models/Client.php
Normal file
67
app/Models/Client.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\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', 'notes', 'avatar',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => ClientStatus::class,
|
||||
];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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('')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user