This package adds messages system to Laravel application based on TALL stack (Tailwind CSS, Alpine.js, Laravel, Livewire).
This package is compatible with Laravel Jetstream package for Livewire stack. If you have it installed and working there are no further steps required.
If you don"t have Laravel Jetstream, you need to have some sort of authentication because the package use Laravels Authenticatable class to get authenticated user. Also, you need to have already installed and working Tailwind CSS, Alpine.js and Livewire.
You can install the package via composer:
composer require vojislavd/laravel-messages
After that you need to publish migrations and config files:
php artisan vendor:publish --tag="laravel-messages-migrations"
php artisan vendor:publish --tag="laravel-messages-config"
Run migration:
php artisan migrate
In your User model class add Messagable
trait:
// App\Models\User.php
use App\Contracts\Messagable;
class User extends Authenticatable
{
use Messagable;
...
}
In tailwind.config.js
file add blade files from this package:
module.exports = {
content: [
"./vendor/vojislavd/laravel-messages/**/*.blade.php", // <-- Add this line
],
theme: {},
plugins: [],
};
Install dependencies and run build process:
npm install && npm run dev
Include the component to your HTML page:
@livewire("inbox")
In config file config\messages.php
you can configure component to automatically refresh and to get new messages, also you can configure refresh interval.
"update" => [
"auto" => true,
"interval" => 750 // milliseconds
],
By default, auto refresh option is disabled.
The Component has a basic filter for forbidden words. In config file you can configure words to be filtered with option to filter exact words or contain text.
"validation" => [
"filter" => [
"exact" => ["exact", "forbidden", "words"],
"contain" => ["contain", "forbidden", "words"],
],
],
If you want to change style of component, you need to publish view file.
php artisan vendor:publish --tag="laravel-messages-views"
Run tests with:
composer test
The MIT License (MIT). Please see License File for more information.