承接 metasync-site/nova-belongs-to-many 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

metasync-site/nova-belongs-to-many

最新稳定版本:1.0.6

Composer 安装命令:

composer require metasync-site/nova-belongs-to-many

包简介

A Laravel Nova field for searchable belongs-to-many relationships

README 文档

README

A Laravel Nova field that provides a searchable interface for belongs-to-many relationships with the ability to create new related resources.

screenshot of the search relations tool

Requirements

  • PHP >=8.2
  • Laravel 11.x | 12.x
  • Laravel Nova 4.x | 5.x

Installation

You can install the package via composer:

composer require metasync-site/nova-belongs-to-many

Usage

use MetasyncSite\NovaBelongsToMany\BelongsToManySearchable;

 BelongsToManySearchable::make('Products')
            ->relationshipConfig(
                resourceClass: ProductResource::class,
                relationName: 'products',
            ),

Full api

use MetasyncSite\NovaBelongsToMany\BelongsToManySearchable;

public function fields(NovaRequest $request)
{
    return [
        BelongsToManySearchable::make('Products')
            ->relationshipConfig(
                resourceClass: ProductResource::class,
                relationName: 'products',
                pivotTable: 'category_product',
                foreignPivotKey: 'category_id',
                relatedPivotKey: 'product_id',
                displayCallback: fn($product) => "{$product->name} (${$product->price})"
            )
            ->withCreateButton(true, 'Add New Product'),
    ];
}

Features

  • 🔍 Searchable interface for belongs-to-many relationships
  • ✨ Custom display formatting with callback support
  • ➕ Optional "Create New" button with modal
  • 🎨 Dark mode support
  • 🎯 Type-safe implementation
  • 🔄 Automatic pivot table management

Configuration Options

Required Parameters

  • resourceClass: The Nova resource class for the related model
  • relationName: The name of the relationship method on your model
  • pivotTable: The name of the pivot table
  • foreignPivotKey: The foreign key of the parent model in the pivot table
  • relatedPivotKey: The foreign key of the related model in the pivot table

Optional Parameters

  • displayCallback: Customize how each option is displayed
  • withCreateButton: Enable the create button with an optional custom label

Security Vulnerabilities

If you discover any security vulnerabilities, please email metasyncsite@gmail.com

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-30