Require this package, with Composer, in the root directory of your project.
$ composer require artisanry/messageable
To get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="Artisanry\Messagable\MessageableServiceProvider" && php artisan migrate
<?php
namespace App;
use Artisanry\Messageable\HasMessages;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasMessages;
}
Thread::create([
'subject' => str_random(10),
]);
$thread->addMessage([
'body' => str_random(10),
], $user);
$thread->addMessage([
[
'data' => ['body' => str_random(10)],
'creator' => User::find(1),
],
[
'data' => ['body' => str_random(10)],
'creator' => User::find(2),
],
], $user);
$thread->addParticipant($user);
$thread->addParticipants([
User::find(3), Organization::find(2), Player::find(4)
]);
$thread->markAsRead($user);
Thread::getAllLatest()->get();
Thread::forModel($user)->latest('updated_at')->get();
Thread::forModelWithNewMessages($user)->latest('updated_at')->get();
$thread->creator();
$thread->getLatestMessage();
$thread->participantsIdsAndTypes();
$thread->isUnread($user);
$thread->hasParticipant($user);
$ phpunit
If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.
This project exists thanks to all the people who contribute.
Mozilla Public License Version 2.0 (MPL-2.0).