enginedigital/model-notes

在eloquent模型上创建笔记。支持多种笔记类型以及多租户模式

1.7.0 2022-05-12 22:38 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

在eloquent模型上创建笔记。支持多种笔记类型以及多租户模式。

安装

您可以通过composer安装此包

composer require enginedigital/model-notes

您可以使用以下命令发布和运行迁移

php artisan vendor:publish --provider="EngineDigital\Note\NoteServiceProvider" --tag="model-notes-migrations"
php artisan migrate

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="EngineDigital\Note\NoteServiceProvider" --tag="model-notes-config"

这是已发布配置文件的内容

return [
    'note_model' => EngineDigital\Note\Note::class,
    'note_default_type' => 'none',
    'note_default_group' => 'admin',
    // key => 'formatter_class_with_invoke',
    // key => ['formatter', 'method'],
    'note_types' => [
        'none' => null, // dont touch formatted output
        'plain' => 'e', // escape in formatted output
        'html' => null, // dont touch formatted output
        'markdown' => [\Illuminate\Support\Str::class, 'markdown'],
        'json' => 'json_decode', // treat the note content as JSON
    ],
    'model_primary_key_attribute' => 'model_id',
    'encrypt_notes' => false,
    'tenant_model' => null, // App\Models\Company::class
    'tenant_resolver' => null, // a class that uses `__invoke` or a container function to get the id of the current tenant
    'author_model' => null, // App\Models\User::class
    'author_resolver' => null, // a class that uses `__invoke` or a container function to get the id of the current user
    'cache_time' => null, // cache time in seconds
    'load_with' => [], // which note relationships to eager load. Example: ['author', 'author.profile', 'author.roles'] or only specific columns ['author:id,name']
];

使用方法

// User model uses EngineDigital\Note\HasNotes
$user->setNote('This is my cute little note!');

测试

composer run test

贡献

有关详细信息,请参阅CONTRIBUTING

致谢

许可协议

MIT许可协议(MIT)。有关更多信息,请参阅许可文件