diff --git a/app/Http/Controllers/DashboardCalendarController.php b/app/Http/Controllers/DashboardCalendarController.php index e71bf6b4..69785492 100644 --- a/app/Http/Controllers/DashboardCalendarController.php +++ b/app/Http/Controllers/DashboardCalendarController.php @@ -33,6 +33,7 @@ public function calendar(Request $request): View $calendarData = Schedule::forTenant($tenantId) ->active() ->betweenDates($startOfWeek->toDateString(), $endOfWeek->toDateString()) + ->withCount('files') ->orderBy('start_date') ->orderBy('start_time') ->get() diff --git a/app/Models/System/Schedule.php b/app/Models/System/Schedule.php index a2ae3ec6..72568aff 100644 --- a/app/Models/System/Schedule.php +++ b/app/Models/System/Schedule.php @@ -2,6 +2,7 @@ namespace App\Models\System; +use App\Models\Boards\File; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; @@ -68,6 +69,12 @@ class Schedule extends Model self::TYPE_OTHER => ['bg' => 'bg-gray-50', 'text' => 'text-gray-700', 'border' => 'border-gray-200'], ]; + public function files() + { + return $this->hasMany(File::class, 'document_id') + ->where('document_type', 'schedule'); + } + public function scopeForTenant(Builder $query, int $tenantId): Builder { return $query->where(function ($q) use ($tenantId) { diff --git a/resources/views/dashboard/partials/calendar.blade.php b/resources/views/dashboard/partials/calendar.blade.php index 08e3b3c9..ca88d771 100644 --- a/resources/views/dashboard/partials/calendar.blade.php +++ b/resources/views/dashboard/partials/calendar.blade.php @@ -125,14 +125,21 @@ class="text-gray-300 hover:text-emerald-600 hover:bg-emerald-50 rounded transiti
@foreach($daySchedules as $schedule) @endforeach