mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-13 00:07:21 +00:00
feat: default notes (#263)
* feat: default notes * feat: include default invoice note in recurring invoice * feat: use default export in tw config * fix: test and naming * fix: consistent ui for switch in note modal * feat: little text improvements
This commit is contained in:
@@ -41,6 +41,15 @@ class NotesController extends Controller
|
||||
|
||||
$note = Note::create($request->getNotesPayload());
|
||||
|
||||
if ($note->is_default) {
|
||||
Note::where('id', '!=', $note->id)
|
||||
->where('type', $note->type)
|
||||
->where('is_default', true)
|
||||
->update([
|
||||
'is_default' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return new NoteResource($note);
|
||||
}
|
||||
|
||||
@@ -68,6 +77,15 @@ class NotesController extends Controller
|
||||
|
||||
$note->update($request->getNotesPayload());
|
||||
|
||||
if ($note->is_default) {
|
||||
Note::where('id', '!=', $note->id)
|
||||
->where('type', $note->type)
|
||||
->where('is_default', true)
|
||||
->update([
|
||||
'is_default' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return new NoteResource($note);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ class NotesRequest extends FormRequest
|
||||
'notes' => [
|
||||
'required',
|
||||
],
|
||||
'is_default' => [
|
||||
'required',
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->isMethod('PUT')) {
|
||||
|
||||
@@ -18,6 +18,7 @@ class NoteResource extends JsonResource
|
||||
'type' => $this->type,
|
||||
'name' => $this->name,
|
||||
'notes' => $this->notes,
|
||||
'is_default' => $this->is_default,
|
||||
'company' => $this->when($this->company()->exists(), function () {
|
||||
return new CompanyResource($this->company);
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user