Skip to content

Repository files navigation

Chat Field

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

bergstar/chat-field provides a Filament 5 form field that renders a record-attached chat window directly inside a form. It stores a single thread per owner record, supports message text and file attachments, and automatically resolves the deepest saved singular relationship record when the field is nested inside a relationship section.

Installation

You can install the package via composer:

composer require bergstar/chat-field

If you use Filament Panels with a custom theme, add the package views to your theme CSS:

@source '../../../../vendor/bergstar/chat-field/resources/**/*.blade.php';

Publish the package assets:

php artisan vendor:publish --tag="chat-field-config"
php artisan vendor:publish --tag="chat-field-migrations"

Then run your migrations:

php artisan migrate

Usage

Add the field to any Filament form:

use Toolborg\ChatField\ChatField;

ChatField::make('chat')

For nested singular relationships, add it inside a relationship layout component:

use Filament\Schemas\Components\Section;
use Toolborg\ChatField\ChatField;

Section::make('Meta')
    ->relationship('meta')
    ->schema([
        ChatField::make('chat'),
    ])

Behavior:

  • One thread is stored per owner record.
  • The current authenticated user becomes the message author.
  • If the owner record does not exist yet, the field renders a save-first state instead of attaching to the wrong model.
  • Nested singular relationship sections use the deepest saved record in the chain.

Configuration

The config file lets you override:

  • thread and message model classes
  • author display name column
  • messages per page
  • upload disk, directory, visibility, mime types, and size limits

Default shape:

return [
    'author_name_column' => 'name',
    'messages_per_page' => 10,
    'uploads' => [
        'disk' => 'public',
        'directory' => 'chat-field-attachments',
        'visibility' => 'public',
        'max_file_size' => 12288,
        'max_files' => 10,
    ],
];

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Chat field for Filament

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages