Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/akshaykhale1992/model-notes

Add Notes against any Laravel Model from any other (or same) Laravel Model
https://github.com/akshaykhale1992/model-notes

eloquent eloquent-models laravel laravel-5-package laravel-framework laravel-package

Last synced: 4 months ago
JSON representation

Add Notes against any Laravel Model from any other (or same) Laravel Model

Awesome Lists containing this project

README

        

# Model Notes
![Scrutinizer Score](https://scrutinizer-ci.com/g/akshaykhale1992/model-notes/badges/quality-score.png?b=master)
![Scrutinizer Build Status](https://scrutinizer-ci.com/g/akshaykhale1992/model-notes/badges/build.png?b=master)

## Introduction
Model Notes is a simple Laravel Package which can be used to add Notes or Comments against any Laravel Eloquent Model.

## Installation
You can pull the package using composer. You may use following command to do that.
```
composer require akshaykhale1992/model-note:dev-master
```

## Usage
The Package contains two Traits `notable` and `creatable`.
`notable` should be used in the model against which you want to add Notes. E.g. Post, Article, Video etc.
`creatable` should be used in the model which is able to create a Note. E.g. User, Admin, Employee etc.

Please Refer following example of simple User and Post Class

#### app/User.php
```
addNote($user, "This is a test Note"); // Adding the Note
```
Alternatively
```
$post = \App\Post::find(3); // Getting the Post to Add Note
$user = \App\User::find(1); // Getting the User who is adding the Note
$user->addingNoteTo($post, "This is a test Note"); // Adding the Note
```

#### Getting Notes from a Post
```
$post = \App\Post::find(3); // Selecting the Post
$user = \App\User::find(1); // Getting the User who has added the Notes
$notes = $post->getNotesBy($user); // Getting notes on a Post by User
```
Alternatively
```
$post = \App\Post::find(3); // Selecting the Post
$user = \App\User::find(1); // Getting the User who has added the Notes
$notes = $user->getNotesOn($post); // Getting notes on a Post by User
```

# License
open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

# Courtesy
- [staudenmeir](https://github.com/staudenmeir)