承接 digital-creative/custom-relationship-field 相关项目开发

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

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

digital-creative/custom-relationship-field

最新稳定版本:v1.1.3

Composer 安装命令:

composer require digital-creative/custom-relationship-field

包简介

Emulate HasMany relationship without having a real relationship set between resources

README 文档

README

Latest Version on Packagist Total Downloads License

Custom Relationship Field in action

This field works just like as the default HasMany relationship field from nova but without requiring a real relation with the resource.

That means you are free to show resource A into the details page of resource B without having to create a real relation between them.

Installation

You can install the package via composer:

composer require digital-creative/custom-relationship-field
use DigitalCreative\CustomRelationshipField\CustomRelationshipField;
use DigitalCreative\CustomRelationshipField\CustomRelationshipFieldTrait;

trait UserWithSimilarNameTrait
{    
    public static function similarNameQuery(NovaRequest $request, Builder $query, User $model): Builder
    { 
        return $query->where('last_name', $model->last_name)->whereKeyNot($model->getKey());
    }
    
    public function similarNameFields(NovaRequest $request): array
    {
        return [
            ID::make(),
            Text::make('First Name'),
            Text::make('Last Name'),
        ];
    }
    
    public function similarNameActions(NovaRequest $request): array 
    {
        return [];
    }

    public function similarNameFilters(NovaRequest $request): array
    {
        return [];
    }
}

class User extends Resource
{    
    use CustomRelationshipFieldTrait;
    use UserWithSimilarNameTrait;
    
    public function fields(NovaRequest $request): array
    {
        return [
            ...
            CustomRelationshipField::make('Users with similar name', 'similarName', User::class),
            ...
        ];
    }
}

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Other Packages You Might Like

License

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

统计信息

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

GitHub 信息

  • Stars: 33
  • Watchers: 4
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-22