ilbronza/timeline 问题修复 & 功能扩展

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

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

ilbronza/timeline

Composer 安装命令:

composer require ilbronza/timeline

包简介

Gantt / timeline visualization components (vis-timeline) for Laravel and IlBronza packages

README 文档

README

Gantt / timeline visualization package (based on vis-timeline) for Laravel projects using the IlBronza package suite.

Extracted from ilbronza/crud to keep the timeline engine decoupled from domain packages.

Installation

composer require ilbronza/timeline

The service provider is auto-discovered.

The host project must load the vis-timeline JS/CSS assets, e.g.:

<script src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vis-timeline@latest/styles/vis-timeline-graph2d.min.css" />

Configuration

php artisan vendor:publish --tag=timeline.config
// config/timeline.php
return [
    // days visible at initial zoom
    'zoom' => 60,

    // model class used to build the drag&drop update route.
    // must use IsTimelineItemTrait (or expose getTimelineUpdateUrl())
    'updatableItemClass' => \IlBronza\Products\Models\Orders\Orderrow::class,
];

If updatableItemClass is null, the Gantt is read-only (drag updates disabled).

Usage

Models

A model rendered as a bar on the timeline:

use IlBronza\Timeline\Interfaces\TimelineItemInterface;
use IlBronza\Timeline\Traits\IsTimelineItemTrait;

class Orderrow extends Model implements TimelineItemInterface
{
    use IsTimelineItemTrait;

    // requires getStartsAt() / getEndsAt() returning ?Carbon
}

A model used as a group (row container) on the timeline:

use IlBronza\Timeline\Interfaces\TimelineGroupInterface;
use IlBronza\Timeline\Interfaces\GanttTimelineInterface;
use IlBronza\Timeline\Traits\IsTimelineGroupTrait;
use IlBronza\Timeline\Traits\GanttTimelineTrait;

class Order extends Model implements TimelineGroupInterface, GanttTimelineInterface
{
    use IsTimelineGroupTrait;
    use GanttTimelineTrait; // provides getGanttUrl() / getGanttButton()
}

Controllers

use IlBronza\Timeline\Http\Controllers\BaseTimelineController;

class OrderTimelineController extends BaseTimelineController
{
    public function getEndpoint() : string
    {
        return route('orders.timeline', $this->getModel());
    }

    public function getMainTimelineData($order)
    {
        $order = $this->findModel($order);

        $this->createGroupsByCollection($groups);
        $this->createItemsByCollectionAndGetter($order->rows, 'getSellable');

        return $this->sendResponse();
    }
}

Two routes per Gantt: container renders the page, timeline returns JSON data:

Route::get('timeline-container/{order}/{option?}', [OrderTimelineController::class, 'container'])->name('orders.timelineContainer');
Route::get('timeline/{order}/{option?}', [OrderTimelineController::class, 'timeline'])->name('orders.timeline');

For project-wide timelines (no specific model) use the GlobalTimelineTrait.

Migrating from ilbronza/crud

Replace the old imports:

Old (IlBronza\CRUD) New (IlBronza\Timeline)
CRUD\Http\Controllers\Timeline\BaseTimelineController Timeline\Http\Controllers\BaseTimelineController
CRUD\Traits\Timeline\GanttTimelineTrait Timeline\Traits\GanttTimelineTrait
CRUD\Traits\Timeline\GlobalTimelineTrait Timeline\Traits\GlobalTimelineTrait
CRUD\Traits\Timeline\IsTimelineItemTrait Timeline\Traits\IsTimelineItemTrait
CRUD\Traits\Timeline\IsTimelineGroupTrait Timeline\Traits\IsTimelineGroupTrait
CRUD\Interfaces\GanttTimelineInterface Timeline\Interfaces\GanttTimelineInterface
CRUD\Interfaces\TimelineInterfaces\TimelineItemInterface Timeline\Interfaces\TimelineItemInterface
CRUD\Interfaces\TimelineInterfaces\TimelineGroupInterface Timeline\Interfaces\TimelineGroupInterface
CRUD\Helpers\TimelineHelpers\TimelineItem Timeline\Helpers\TimelineItem
CRUD\Helpers\TimelineHelpers\TimelineGroup Timeline\Helpers\TimelineGroup
CRUD\Helpers\TimelineHelpers\TimelineItemCreatorHelper Timeline\Helpers\TimelineItemCreatorHelper
CRUD\Helpers\TimelineHelpers\TimelineGroupCreatorHelper Timeline\Helpers\TimelineGroupCreatorHelper

Config changes:

  • crud.timelineZoomtimeline.zoom
  • set timeline.updatableItemClass (was hardcoded to Orderrow in CRUD)

View changes:

  • crud::timeline.timelinetimeline::timeline

After migrating, the Timeline folders in ilbronza/crud (src/Traits/Timeline, src/Http/Controllers/Timeline, src/Helpers/TimelineHelpers, src/Interfaces/TimelineInterfaces, src/Interfaces/GanttTimelineInterface.php, resources/views/timeline) can be removed.

License

MIT

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固