tomodo531/filterable-filters 问题修复 & 功能扩展

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

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

tomodo531/filterable-filters

最新稳定版本:2.0.0

Composer 安装命令:

composer require tomodo531/filterable-filters

包简介

A Laravel Nova filter.

README 文档

README

This package can create filters based on the columns in your database. It can also filter out unused options.

composer require tomodo531/filterable-filters

Filterable Filters

Example:

Model:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'content',
    ];

    public function categories()
    {
        return $this->belongsToMany(Category::class, 'category_article');
    }

    public function author()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}

Fields:

public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable(),

            Text::make('Title')
                ->required(),

            Textarea::make('Content')
                ->required(),

            BelongsTo::make('Author', 'author', User::class),

            BelongsToMany::make('Categories'),
        ];
    }

Filters:

    public function filters(NovaRequest $request)
    {
        return [
            FilterableFilters::make(\App\Models\Article::class)
                ->fields([
                    'title', // if the field is not relational then just write the name of the database column.
                    'content',
                    'author' => [
                        'title' => 'name', // Works like the title in a nova resource. This is the name of the column that will be shown in the selector.
                        'primarykey' => 'id', // The primary key of the relational tabel. In this example the primary key of the auther or user table is 'id'.
                        'foreignkey' => 'user_id' // The foreign key in the nova resource model.
                    ],
                ]),                
        ];
    }

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固