initial commit

This commit is contained in:
I-Fun
2026-04-01 08:04:56 +07:00
commit e09c8a5fa9
111 changed files with 18022 additions and 0 deletions

48
app/Models/Event.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Enums\EventStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Event extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'client_id', 'title', 'description', 'event_type',
'start_time', 'end_time', 'location', 'is_priority',
'is_all_day', 'status', 'color', 'notes',
];
protected $casts = [
'start_time' => 'datetime',
'end_time' => 'datetime',
'is_priority' => 'boolean',
'is_all_day' => 'boolean',
'status' => EventStatus::class,
];
public function client(): BelongsTo
{
return $this->belongsTo(Client::class);
}
public function scopeUpcoming($query, int $hours = 24)
{
return $query->where('start_time', '>=', now())
->where('start_time', '<=', now()->addHours($hours))
->where('status', '!=', EventStatus::Completed->value)
->where('status', '!=', EventStatus::Cancelled->value);
}
public function scopeToday($query)
{
return $query->whereDate('start_time', today());
}
}