Installation
composer require tomatophp/filament-notes
Publish the migration and config:
php artisan vendor:publish --provider="TomatoPHP\FilamentNotes\FilamentNotesServiceProvider" --tag="filament-notes:migrations"
php artisan vendor:publish --provider="TomatoPHP\FilamentNotes\FilamentNotesServiceProvider" --tag="filament-notes:config"
Run migrations:
php artisan migrate
Register the Resource
Add to app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->resources([
// ... other resources
\TomatoPHP\FilamentNotes\Resources\NoteResource::class,
]);
}
First Use Case
Access /admin/resources/notes to create your first note. Use the Notes Widget (drag-and-drop) to pin it to your dashboard.
Note Creation & Management
group_id field) to categorize notes (e.g., "Dev Tasks," "Client Notes").is_public to true for team-wide visibility (requires proper Filament permissions).Styling Notes
// Override defaults in config/filament-notes.php:
'default_background' => '#f0f0f0',
'default_font_color' => '#333',
'default_border_color' => '#ddd',
Dashboard Integration
// In a Filament widget class:
public static function canAccess(): bool
{
return true; // Or use Filament's auth gates
}
public function getWidgetData(): array
{
return [
'notes' => \TomatoPHP\FilamentNotes\Models\Note::query()
->where('is_pinned', true)
->limit(5)
->get(),
];
}
config/filament-notes.php:
'widget_limit' => 5, // Max pinned notes shown
Programmatic Access
use TomatoPHP\FilamentNotes\Models\Note;
$notes = Note::where('group_id', 1)->get();
Note::create([
'title' => 'API Reminder',
'content' => 'Check rate limits',
'group_id' => 2,
'is_pinned' => true,
'background_color' => '#fff2cc', // "Warning" style
]);
Permissions
// app/Policies/NotePolicy.php
public function viewAny(User $user): bool
{
return $user->can('view notes'); // Custom gate
}
SQLite3 Dependency
# Ubuntu/Debian
sudo apt-get install php-sqlite3
# macOS (Homebrew)
brew install php
config/filament-notes.php:
'icon_fallback_path' => 'path/to/local/icon.png',
Widget Caching
php artisan filament:cache:clear
is_pinned + updated_at to force refreshes:
->where('updated_at', '>', now()->subMinutes(5))
Style Inheritance
style_id or inline overrides:
'background_color' => '#ffeb3b', // Overrides default
'font_color' => '#888',
Group Management
hasNotes() check:
// In a policy or query:
->whereHas('notes')
Permission Granularity
is_public with Filament’s Resource Policies:
public function edit(User $user, Note $note): bool
{
return $user->can('edit notes') || ($note->is_public && $user->can('view public notes'));
}
.env:
DB_LOG_QUERIES=true
// In a service provider:
event(new \TomatoPHP\FilamentNotes\Events\NoteUpdated($note));
Route::get('/debug-notes', function () {
dd(\TomatoPHP\FilamentNotes\Widgets\NotesWidget::getWidgetData());
});
Custom Note Fields
Note model:
// app/Models/Note.php
public function castAttributes(): array
{
return array_merge(parent::castAttributes(), [
'priority' => 'integer',
]);
}
// In NoteResource.php
public static function form(Form $form): Form
{
return $form->schema([
// ... existing fields
Select::make('priority')
->options([1 => 'Low', 2 => 'Medium', 3 => 'High']),
]);
}
Dynamic Styling
// app/Observers/NoteObserver.php
public function saved(Note $note)
{
if ($note->priority === 3) {
$note->update(['background_color' => '#ffcccb']);
}
}
NoteServiceProvider:
Note::observe(NoteObserver::class);
API Endpoints
// routes/api.php
Route::get('/notes', [\TomatoPHP\FilamentNotes\Http\Controllers\NoteController::class, 'index']);
return Note::where('group_id', request('group_id'))->get();
Webhook Triggers
// In NoteObserver.php
public function created(Note $note)
{
event(new \TomatoPHP\FilamentNotes\Events\NoteCreated($note));
}
Event::listen(\TomatoPHP\FilamentNotes\Events\NoteCreated::class, function ($event) {
// Send Slack notification, etc.
});
Localization
// lang/en/filament-notes.php
return [
'resources' => [
'note' => [
'singular' => 'Memo',
'plural' => 'Memos',
],
],
];
How can I help you explore Laravel packages today?