定制 spatie/laravel-there-there 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

spatie/laravel-there-there

Composer 安装命令:

composer require spatie/laravel-there-there

包简介

Expose application data as JSON for There There

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package makes it easy to expose application data to There There. When a customer opens a ticket in There There, it will call your application to fetch relevant data and display it in the sidebar.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-there-there

You can publish the config file with:

php artisan vendor:publish --tag="there-there-config"

This is the contents of the published config file:

return [
    'secret' => env('THERE_THERE_SECRET'),
    'url' => '/there-there',
    'middleware' => [
        Spatie\ThereThere\Http\Middleware\IsValidThereThereRequest::class,
        'api',
    ],
];

Add the secret to your .env file. You can find it in your There There workspace settings.

THERE_THERE_SECRET=your-secret-here

Usage

In a service provider (for example AppServiceProvider), register a sidebar callback using the ThereThere facade:

use Spatie\ThereThere\Facades\ThereThere;
use Spatie\ThereThere\SidebarItem;
use Spatie\ThereThere\Http\Requests\ThereThereRequest;

ThereThere::sidebar(function (ThereThereRequest $request) {
    $user = User::firstWhere('email', $request->email());

    if (! $user) {
        return [];
    }

    return [
        SidebarItem::markdown('Name', $user->name),
        SidebarItem::date('Registered at', $user->created_at),
        SidebarItem::numeric('Total orders', $user->orders()->count()),
        SidebarItem::boolean('Is subscribed', $user->subscribed()),
    ];
});

Each SidebarItem has a name, value, and type. The following types are available:

Type Method Value
numeric SidebarItem::numeric($name, $value) An integer or float
markdown SidebarItem::markdown($name, $value) A string (supports Markdown)
date SidebarItem::date($name, $value) A DateTimeInterface or ISO 8601 string
boolean SidebarItem::boolean($name, $value) A boolean

The package will respond with JSON in this format:

{
    "data": [
        {"name": "Name", "value": "John Doe", "type": "markdown"},
        {"name": "Registered at", "value": "2024-01-15T10:30:00+00:00", "type": "date"},
        {"name": "Total orders", "value": 42, "type": "numeric"},
        {"name": "Is subscribed", "value": true, "type": "boolean"}
    ]
}

Security

All requests are verified using HMAC-SHA256 signatures. The package will reject any request without a valid X-There-There-Signature header.

Testing

composer test

Changelog

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

Credits

License

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

统计信息

  • 总下载量: 3.75k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固