kcesys/laravel-inertia-genealogy 问题修复 & 功能扩展

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

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-15