Download the PHP package icodestuff/laravel-notes without Composer
On this page you can find all versions of the php package icodestuff/laravel-notes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download icodestuff/laravel-notes
More information about icodestuff/laravel-notes
Files in icodestuff/laravel-notes
Package laravel-notes
Short Description Provides the ability to add notes to your Eloquent models in Laravel.
License MIT
Homepage https://github.com/icodestuff-io/laravel-notes
Informations about the package laravel-notes
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
- Installation and Setup
- Configuration
- Usage
- Contribution Guidelines
- Security
- 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 theHasManyNotes
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 [email protected] instead of using the issue tracker.