kcesys/laravel-inertia-genealogy
Composer 安装命令:
composer require kcesys/laravel-inertia-genealogy
包简介
Laravel bridge for KCESYS Genealogy library with Inertia support
README 文档
README
A Laravel bridge for kcesys/php-genealogy designed for seamless integration with Inertia.js.
Installation
composer require kcesys/laravel-inertia-genealogy
Features
- Fluent Helper:
Genealogy::for($data)wrapper. - Inertia Integration:
share()method to automatically inject props. - Auto-Discovery: Automatically transforms Eloquent Models.
Usage
In your Controller:
use KCESYS\LaravelGenealogy\Genealogy; use App\Models\User; use Inertia\Inertia; public function index() { $family = User::with('parents', 'children')->get(); // Option 1: Pass as Prop return Inertia::render('MyTree', [ 'graph' => Genealogy::for($family)->toGraph([ 'label' => 'full_name', // Map 'label' to 'full_name' attribute 'spouses' => fn($u) => $u->partners->pluck('id') // Custom relationship mapping ]) ]); }
Sharing Globally
If you want the genealogy data available on every page (e.g. for a sidebar widget):
// In HandleInertiaRequests Middleware public function share(Request $request) { return array_merge(parent::share($request), [ 'genealogy' => fn() => Genealogy::for($request->user()->family)->toGraph() ]); }
统计信息
- 总下载量: 130
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-15