organization = $organization; if ($todo?->exists) { $this->todo = $todo; $this->title = $todo->title; $this->description = $todo->description ?? ''; $this->category = $todo->category; $this->criticality = $todo->criticality; $this->due_date = $todo->due_date?->format('Y-m-d'); $this->assigned_to = $todo->assigned_to; } } public function save(): void { $validated = $this->validate([ 'title' => 'required|string|max:255', 'description' => 'nullable|string', 'category' => 'required|in:'.implode(',', array_keys(Todo::CATEGORIES)), 'criticality' => 'required|in:'.implode(',', array_keys(Todo::CRITICALITIES)), 'due_date' => 'nullable|date', 'assigned_to' => 'nullable|exists:users,id', ]); if ($this->todo?->exists) { $this->todo->update($validated); session()->flash('status', "Tâche \"{$this->todo->title}\" mise à jour."); } else { $this->organization->todos()->create([ ...$validated, 'created_by' => auth()->id(), ]); session()->flash('status', "Tâche \"{$this->title}\" créée."); } $this->redirectRoute('organizations.todos.index', $this->organization, navigate: true); } public function with(): array { return [ 'assignableUsers' => User::role(['Administrateur', 'Technicien'])->orderBy('name')->get(), ]; } }; ?>

{{ $organization->name }}

{{ $todo?->exists ? 'Modifier la tâche' : 'Nouvelle tâche' }}

@error('title')

{{ $message }}

@enderror
@error('due_date')

{{ $message }}

@enderror
Annuler
@if ($todo?->exists)
@endif