Notes
The Notes module adds polymorphic notes for resources.
Use it when users need a comment/history stream attached to multiple resource models.
Install
composer require qore-next/notes
The package auto-discovers NotesServiceProvider.
Publish migrations:
php artisan vendor:publish --tag=qore-next.notes.db
php artisan migrate
The module also has publishable config:
php artisan vendor:publish --tag=qore-next.notes.config
Usage
Add the relation trait to a model:
use Qore\Next\Notes\Model\HasNotes;
class Customer extends Model
{
use HasNotes;
}
Show notes with a field:
NotesField::make();
Or add the card manually:
new NotesCard($resource, $model);
Register the frontend module in resources/js/app.tsx so the notes icon and frontend setup are loaded:
import notesModule from '../../vendor/qore-next/notes/resources/js'
<QoreAppProvider
app={{
// ...
modules: [notesModule]
}}
/>
Configure
The config defines the note model, policy and resource classes. Helpers read these values:
notes_model_class()notes_policy_class()notes_resource_class()notes_resource_instance()
Enable the module in Qore's modules UI. On enable it creates CRUDA permissions for notes; on disable it deletes the notes permission category.
Boot Behaviour
When enabled, the module:
- registers the note policy;
- registers
NoteResource; - loads routes from
routes.php; - loads translations and migrations.