| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Http\Livewire\Traits;
- use App\Models\ReportProtocolloNote;
- trait HasNote{
- public $noteText;
- public $notes;
- public function addNote()
- {
- ReportProtocolloNote::create([
- 'report_id' => $this->dataId,
- 'text' => $this->noteText,
- 'created' => now(),
- 'created_by' => auth()->id() ?? 0,
- ]);
- $this->noteText = '';
- $this->refreshNotes();
- }
- public function removeNote($id)
- {
- ReportProtocolloNote::findOrFail($id)->delete();
- $this->refreshNotes();
- }
- private function refreshNotes()
- {
- $this->notes = ReportProtocolloNote::where('report_id', $this->dataId)->get();
- }
- }
|