Skip to content
This repository was archived by the owner on Aug 14, 2022. It is now read-only.

Jam0r85/nova-notes-field

Repository files navigation

Nova Notes Field

This package is based on the original Nova Notes Field package by Tarvo Reinpalu.

All credit goes to Tarvo Reinpalu for creating a fantastic addition to Nova. The core features of the original package are the same however there are some layout tweaks and I hope to add additional features such as stuck/important notes, latest note cards, etc.

Features

  • Notes field on Detail view
  • Differentiation between user-added and system-added notes
  • Ability to add notes through the UI or programmatically
  • Ability to delete user-made notes (w/ confirmation modal)
  • Customizable placeholder support

Installation

# Install the package via Composer
composer require jam0r85/nova-notes-field

# Run automatically loaded migration(s)
php artisan migrate

Usage

Add HasNotes trait to the model that has the notes:

use Jam0r85\NovaNotesField\Traits\HasNotes;

class ExampleModel extends Model
{
    use HasNotes;
}

Add NotesField to the matching resource:

use Jam0r85\NovaNotesField\NotesField;

class SomeResource extends Resource
{
  // ...

  public function fields(Request $request)
  {
    return [
      // ...
      NotesField::make('Notes')
        ->placeholder('Add note'), // Optional
    ]
  }
}

Adding notes programmatically

To add notes programmatically, use the method provided by the HasNotes trait:

/**
 * Creates a new note and attaches it to the model.
 *
 * @param string $note The note text which can contain raw HTML.
 * @param bool $user Enables or disables the use of `Auth::user()` to set as the creator.
 * @param bool $system Defines whether the note is system created and can be deleted or not.
 * @return \Jam0r85\NovaNotesField\Models\Note
 **/
public function addNote($note, $user = true, $system = true)

Credits

License

This project is open-sourced software licensed under the MIT license.

nova-notes-field

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors