1. Go to this page and download the library: Download tmsllc/laravel-model-note library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tmsllc / laravel-model-note example snippets
// add a note
$model->addNote('needs manager approve');
// add another note
$model->addNote('manager approved');
// get the current status
$model->notes(); // returns a collection of \TMSLLC\ModelNotes\Note
// get the last note
$lastNote = $model->lastNote(); // returns an instance of \TMSLLC\ModelNotes\Note
return [
/*
* The class name of the notes model that holds all notes.
*
* The model must be or extend `TMSLLC\ModelNote\Note`.
*/
'note_model' => TMSLLC\ModelNote\Note::class,
/*
* The name of the column which holds the ID of the model related to the notes.
*
* You can change this value if you have set a different name in the migration for the notes table.
*/
'model_primary_key_attribute' => 'model_id',
];
use TMSLLC\ModelNote\HasNotes;
class YourEloquentModel extends Model
{
use HasNotes;
}
$model->addNote('whatever you like');
$model->addNote('whatever you like' , true);
//or alternatively
$model->addPrivateNote('whatever you like');
$model->addNote('whatever you like' , false , "tag1");
//or for the private note
$model->addPrivateNote('whatever you like' , "tag2");
$model->note; // returns the text of the last note
$model->note(); // returns the last instance of `TMSLLC\ModelNote\Note`
//or alternatively
$model->lastNote(); // returns the last instance of `TMSLLC\ModelNote\Note`
//last note of specific tag
$last_note = $model->lastNote("tag1");
//specific tag
$all_notes = $model->allNotes("tag1");
//specific tags
$all_notes = $model->allNotes("tag1" , "tag2");