Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/akshaykhale1992/model-notes
- Owner: akshaykhale1992
- License: mit
- Created: 2018-08-31T07:03:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-09T07:43:10.000Z (over 6 years ago)
- Last Synced: 2024-09-28T20:05:08.975Z (4 months ago)
- Topics: eloquent, eloquent-models, laravel, laravel-5-package, laravel-framework, laravel-package
- Language: PHP
- Homepage: https://akshaykhale1992.github.io/model-notes/
- Size: 16.6 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)