digitlimit/inbox 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitlimit/inbox

最新稳定版本:v1.0.0

Composer 安装命令:

composer require digitlimit/inbox

包简介

Laravel messages and inbox system

README 文档

README

This Laravel package will help you to create an inbox system and send messages between users easily. This package was forked from https://github.com/digitlimit/laravel-inbox.

Changes

  • Fix Inbox listing issue, Inbox now only list received massages
  • Add default avatar from https://ui-avatars.com/
  • Fix labels on Inbox & Sent Item tabs
  • Add separate route and controller for sent items

Installation

This package can be installed through Composer.

composer require digitlimit/laravel-inbox

If you don't use Laravel 5.5+ you have to add the service provider manually

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

You can publish migrations, config, views, lang files

php artisan vendor:publish --provider="Digitlimit\Inbox\InboxServiceProvider" 

This is the contents of the published config file:

<?php

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' => Digitlimit\Inbox\Models\Thread::class,
        'message' => Digitlimit\Inbox\Models\Message::class,
        'participant' => Digitlimit\Inbox\Models\Participant::class,
    ],

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

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

Usage

First, we need to use HasInbox trait so users can have their inbox:

<?php

namespace App;

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

class User extends Authenticatable
{
    use Notifiable, HasInbox;
}

Get user threads:

$user->threads()

Get unread messages:

$thread = $user->unread()

Get the threads that have been sent by a user:

$thread = $user->sent()

Get the threads that have been sent to the user:

$thread = $user->received()

Send new thread:

  • subject(): your message subject
  • writes(): your message body
  • to(): array of users ID that you want them to receive your message
  • send(): to send your message
$thread = $user->subject($request->subject)
            ->writes($request->body)
            ->to($request->recipients)
            ->send();

Reply for thread:

  • reply() an object for your thread
$message = $user->writes($request->body)
                ->reply($thread);

Check if the thread has any unread messages:

if ($thread->isUnread())

License

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

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-05-21