PHP code example of multicaret / laravel-inbox

1. Go to this page and download the library: Download multicaret/laravel-inbox library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

multicaret / laravel-inbox example snippets


// config/app.php
'providers' => [
    ...
    Multicaret\Inbox\InboxServiceProvider::class,
    ...
];



return [

    'paginate' => 10,

    /*
    |--------------------------------------------------------------------------
    | Inbox Route Group Config
    |--------------------------------------------------------------------------
    |
    | ..
    |
    */

    'route' => [
        'prefix' => 'inbox',
        'middleware' => ['web', 'auth'],
        'name' => null
    ],

    /*
    |--------------------------------------------------------------------------
    | Inbox Tables Name
    |--------------------------------------------------------------------------
    |
    | ..
    |
    */

    'tables' => [
        'threads' => 'threads',
        'messages' => 'messages',
        'participants' => 'participants',
    ],

    /*
    |--------------------------------------------------------------------------
    | Models
    |--------------------------------------------------------------------------
    |
    | If you want to overwrite any model you should change it here as well.
    |
    */

    'models' => [
        'thread' => Multicaret\Inbox\Models\Thread::class,
        'message' => Multicaret\Inbox\Models\Message::class,
        'participant' => Multicaret\Inbox\Models\Participant::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Inbox Notification
    |--------------------------------------------------------------------------
    |
    | Via Supported: "mail", "database", "array"
    |
    */

    'notifications' => [
        'via' => [
            'mail',
        ],
    ],
];



namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Multicaret\Inbox\Traits\HasInbox;

class User extends Authenticatable
{
    use Notifiable, HasInbox;
}

$user->threads()

$thread = $user->unread()

$thread = $user->sent()

$thread = $user->received()

$thread = $user->subject($request->subject)
            ->writes($request->body)
            ->to($request->recipients)
            ->send();

$message = $user->writes($request->body)
                ->reply($thread);

if ($thread->isUnread())
 bash
php artisan vendor:publish --provider="Multicaret\Inbox\InboxServiceProvider" --tag="config"