Files
Kol-Manager/app/Models/Event.php
I-Fun 22f03ccca7 Add contract management and invoice settings pages
- Created a new Blade view for managing brand contracts with forms for adding and editing contracts, including client and category selection.
- Implemented success message notifications for contract actions.
- Added a new Blade view for invoice settings, allowing customization of invoice number format, header branding, and default values for new invoices.
- Introduced a new PDF view for generating rate cards with customizable styles based on user profile settings.
- Developed a profile management page for rate cards, enabling users to update their identity, appearance, and visibility settings.
2026-04-01 21:47:34 +07:00

54 lines
1.4 KiB
PHP

<?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', 'category_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 category(): BelongsTo
{
return $this->belongsTo(ClientCategory::class, 'category_id');
}
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());
}
}