PHPackages                             vuer/notes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vuer/notes

ActiveUtils[Utility &amp; Helpers](/categories/utility)

vuer/notes
==========

Model notes.

1.1.0(9y ago)16.7k↓33.3%MITPHP

Since Oct 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/vuer/notes)[ Packagist](https://packagist.org/packages/vuer/notes)[ RSS](/packages/vuer-notes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Notes (Laravel 5 Package)
=========================

[](#notes-laravel-5-package)

[![Latest Stable Version](https://camo.githubusercontent.com/f4ad1cf5a1602807825b876fbc40818c1c5306290739c397c3680d686042465a/68747470733a2f2f706f7365722e707567782e6f72672f767565722f6e6f7465732f762f737461626c65)](https://packagist.org/packages/vuer/notes) [![Total Downloads](https://camo.githubusercontent.com/1c593f64e3a0e9280e516bfd67930a23166a185515e2481b1fcbc68f3d46783b/68747470733a2f2f706f7365722e707567782e6f72672f767565722f6e6f7465732f646f776e6c6f616473)](https://packagist.org/packages/vuer/notes) [![Latest Unstable Version](https://camo.githubusercontent.com/a584d79216d23de0c07697149e142a4768c7930167a31b34784db19e4e94400c/68747470733a2f2f706f7365722e707567782e6f72672f767565722f6e6f7465732f762f756e737461626c65)](https://packagist.org/packages/vuer/notes) [![License](https://camo.githubusercontent.com/5a988250c939dda010a5e9ad874c6199be2989bd3804f64365b571d68d760b0e/68747470733a2f2f706f7365722e707567782e6f72672f767565722f6e6f7465732f6c6963656e7365)](https://packagist.org/packages/vuer/notes)

Installation
------------

[](#installation)

You can install this package via composer using this command:

```
composer require vuer/notes

```

Next, you must install the service provider:

```
// config/app.php
'providers' => [
    ...
    Vuer\Notes\NotesServiceProvider::class,
];
```

Publish migration and configuration file:

```
php artisan vendor:publish

```

After the migration has been published you can create the notes table by running the migrations:

```
php artisan migrate

```

If you want you can change models in notes config file (config/notes.php):

```
  /*
   * The class name of the note model to be used.
   */
  'note_model' => \Vuer\Notes\Models\Note::class,

  /*
   * The class name of the author model to be used.
   */
  'author_model' => \App\User::class,

```

Usage
-----

[](#usage)

### Preparing your model

[](#preparing-your-model)

To associate notes with a model, the model must implement the following trait:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Vuer\Notes\Traits\HasNotes;

class User extends Model
{
    use HasNotes;
    ...
}
```

### Creating notes

[](#creating-notes)

You can create a note for the model like this:

```
$user = User::find(1);
$note = $user->createNote(['body' => 'Lorem ipsum...']);
```

To save note author you should add second parameter:

```
$note = $user->createNote(['body' => 'Lorem ipsum...'], \Auth::user());
```

If you want to save author name you need to create **getNotesAuthorName** method in author class. It is useful if you want to delete users and keep informations about notes authors.

```
