定制 icodestuff/laravel-notes 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

icodestuff/laravel-notes

最新稳定版本:1.0.3

Composer 安装命令:

composer require icodestuff/laravel-notes

包简介

Provides the ability to add notes to your Eloquent models in Laravel.

README 文档

README

Logo Laravel Pint

Packagist License Github Workflow Status Coverage Status Packagist Downloads

Laravel Notes is a flexible and easy-to-use package that adds a notes system to your Laravel application. It’s well-tested, highly configurable, and works seamlessly with multiple Laravel versions.

Features

  • Flexible notes system.
  • Easy setup & configuration.
  • IDE-friendly and well-documented.

Table of Contents

  1. Installation and Setup
  2. Configuration
  3. Usage
  4. Contribution Guidelines
  5. Security
  6. Credits

1. Installation and Setup

Installation via Composer

Install the package using Composer:

composer require icodestuff/laravel-notes

Setup for Laravel

Note: This package will automatically register itself for Laravel >= 5.5.

For earlier versions, manually register the service provider in config/app.php:

'providers' => [
    // Other service providers...
    Icodestuff\LaravelNotes\LaravelNotesServiceProvider::class,
],

Publish the configuration file:

php artisan vendor:publish --provider="Icodestuff\LaravelNotes\LaravelNotesServiceProvider"

2. Configuration

Customize the package by editing config/notes.php:

return [
    'database' => [
        'connection' => env('DB_CONNECTION', 'mysql'),
        'prefix'     => null,
    ],
    'authors' => [
        'table' => 'users',
        'model' => App\User::class,
    ],
    'notes' => [
        'table' => 'notes',
        'model' => Icodestuff\LaravelNotes\Models\Note::class,
    ],
];

3. Usage

Adding Notes to Models

Use the HasManyNotes trait in your model:

use Icodestuff\LaravelNotes\Traits\HasManyNotes;

class Post extends Model {
    use HasManyNotes;
}

Add a note:

$post = App\Post::first();
$note = $post->createNote('This is a note!');

Add a note with an author:

$user = App\User::first();
$note = $post->createNote('Note with author', $user);

Retrieve notes:

$notes = $post->notes;

Using the HasOneNote Trait

For managing a single note on a model, use the HasOneNote trait:

use Icodestuff\LaravelNotes\Traits\HasOneNote;

class Post extends Model {
    use HasOneNote;
}

Access the note:

$note = $post->note;

Retrieve Author's Notes

Add the AuthoredNotes trait to your User model to retrieve all notes authored by a user:

use Icodestuff\LaravelNotes\Traits\AuthoredNotes;

class User extends Model {
    use AuthoredNotes;
}

Retrieve the author's notes:

$user = App\User::first();
$notes = $user->authoredNotes;

Find a Specific Note by ID

To find a note by its ID:

$post = App\Post::first();
$note = $post->findNote(1);

Note: The findNote method is only available in the HasManyNotes trait.

Contribution

Feel free to submit any issues or pull requests! Please read the contribution guidelines first.

Security

If you discover any security issues, please email arcanedev.maroc@gmail.com instead of using the issue tracker.

Credits

统计信息

  • 总下载量: 662
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固