validate([ 'newLogCategory' => 'required|in:'.implode(',', array_keys(\App\Models\OrganizationLogEntry::CATEGORIES)), 'newLogNote' => 'required|string', ]); $this->organization->logEntries()->create([ 'category' => $this->newLogCategory, 'note' => $this->newLogNote, 'created_by' => auth()->id(), ]); $this->newLogNote = ''; } public function deleteLogEntry(int $entryId): void { $this->organization->logEntries()->findOrFail($entryId)->delete(); } public function toggleTodoDone(int $todoId): void { $todo = $this->organization->todos()->findOrFail($todoId); $todo->update([ 'is_done' => ! $todo->is_done, 'completed_at' => $todo->is_done ? null : now(), ]); } public function previousActivityPage(): void { $this->activityPage = max(1, $this->activityPage - 1); } public function nextActivityPage(): void { $this->activityPage++; } public function with(): array { $expiringDomains = $this->organization->domains() ->get() ->filter(fn ($domain) => in_array($domain->expiryStatus(), ['soon', 'expired'], true)) ->sortBy(fn ($domain) => $domain->expiresInDays()); $recentDocuments = $this->organization->documents() ->with('creator') ->where('is_folder', false) ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($doc) => [ 'icon' => $doc->isOffice() ? ($doc->office_extension === 'xlsx' ? '📊' : '📘') : ($doc->isMarkdown() ? '📝' : '📄'), 'label' => $doc->name, 'kind' => 'Document', 'url' => route('organizations.documents.edit', [$this->organization, $doc]), 'creator' => $doc->creator?->name, 'created' => $doc->created_at->equalTo($doc->updated_at), 'at' => $doc->updated_at, ]); $recentAssets = $this->organization->flexibleAssets() ->with(['type', 'creator']) ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($asset) => [ 'icon' => $asset->type?->icon ?: '🗂️', 'label' => $asset->name, 'kind' => $asset->type?->name ?? 'Actif', 'url' => route('organizations.assets.edit', [$this->organization, $asset->type, $asset]), 'creator' => $asset->creator?->name, 'created' => $asset->created_at->equalTo($asset->updated_at), 'at' => $asset->updated_at, ]); $recentVirtualMachines = $this->organization->virtualMachines() ->with('creator') ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($vm) => [ 'icon' => '🖥️', 'label' => $vm->name, 'kind' => 'Machine virtuelle', 'url' => route('organizations.virtual-machines.edit', [$this->organization, $vm]), 'creator' => $vm->creator?->name, 'created' => $vm->created_at->equalTo($vm->updated_at), 'at' => $vm->updated_at, ]); $allActivity = $recentDocuments ->concat($recentAssets) ->concat($recentVirtualMachines) ->sortByDesc('at') ->values(); $activityPageCount = max(1, (int) ceil($allActivity->count() / self::ACTIVITY_PER_PAGE)); $this->activityPage = min($this->activityPage, $activityPageCount); $recentActivity = $allActivity->forPage($this->activityPage, self::ACTIVITY_PER_PAGE)->values(); $openTodos = $this->organization->todos() ->with('assignee') ->where('is_done', false) ->orderByRaw("CASE criticality WHEN 'urgent' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 ELSE 3 END") ->orderByRaw('due_date IS NULL') ->orderBy('due_date') ->limit(8) ->get(); return [ 'counts' => [ 'contacts' => $this->organization->contacts()->count(), 'locations' => $this->organization->locations()->count(), 'domains' => $this->organization->domains()->count(), 'documents' => $this->organization->documents()->where('is_folder', false)->count(), 'virtualMachines' => $this->organization->virtualMachines()->count(), 'assets' => $this->organization->flexibleAssets()->count(), 'openTodos' => $this->organization->todos()->where('is_done', false)->count(), ], 'expiringDomains' => $expiringDomains, 'recentActivity' => $recentActivity, 'activityPageCount' => $activityPageCount, 'openTodos' => $openTodos, 'logEntries' => $this->organization->logEntries()->with('creator')->limit(20)->get(), 'categories' => \App\Models\OrganizationLogEntry::CATEGORIES, ]; } }; ?>

Tableau de bord

{{ $organization->name }}

Logo {{ $organization->name }}
{{ $counts['contacts'] }} Contacts {{ $counts['locations'] }} Sites {{ $counts['domains'] }} Domaines {{ $counts['documents'] }} Documents {{ $counts['virtualMachines'] }} Machines virtuelles {{ $counts['assets'] }} Actifs {{ $counts['openTodos'] }} Tâches ouvertes

Domaines à surveiller

@if ($expiringDomains->isEmpty())

Aucun domaine à surveiller.

@else
    @foreach ($expiringDomains as $domain)
  • {{ $domain->name }} {{ $domain->expiryStatus() === 'expired' ? 'Expiré' : 'Expire dans '.$domain->expiresInDays().' j' }}
  • @endforeach
@endif

Activité récente

    @forelse ($recentActivity as $activity)
  • {{ $activity['icon'] }} {{ $activity['label'] }} {{ $activity['at']->diffForHumans() }}

    {{ $activity['kind'] }} {{ $activity['created'] ? 'créé' : 'modifié' }} @if ($activity['creator']) par {{ $activity['creator'] }} @endif

  • @empty
  • Aucune activité récente.
  • @endforelse
@if ($activityPageCount > 1)
Page {{ $activityPage }} / {{ $activityPageCount }}
@endif
    @forelse ($openTodos as $todo)
  • {{ $todo->title }}

    {{ $todo->categoryLabel() }} @if ($todo->assignee) · {{ $todo->assignee->name }} @endif @if ($todo->due_date) · {{ $todo->due_date->format('d/m/Y') }} @endif

    {{ $todo->criticalityLabel() }}
  • @empty
  • Aucune tâche ouverte.
  • @endforelse

Journal de bord

@error('newLogNote')

{{ $message }}

@enderror
@forelse ($logEntries as $entry)
{{ $entry->categoryLabel() }}

{{ $entry->note }}

{{ $entry->creator?->name ?? 'système' }} · {{ $entry->created_at->diffForHumans() }}

@empty

Aucune entrée dans le journal pour le moment.

@endforelse