承接 codenco-dev/nova-grid-system 相关项目开发

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

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

codenco-dev/nova-grid-system

Composer 安装命令:

composer require codenco-dev/nova-grid-system

包简介

A Laravel Nova tool to have a grid system

README 文档

README

#Nova grid system for Laravel Nova

Install

You can install this package via composer:

composer require codenco-dev/nova-grid-system

Then, you will need to register the tool within the NovaServiceProvider.php:

use CodencoDev\NovaGridSystem\NovaGridSystem;

/**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        return [
        //other tools
            new NovaGridSystem
        ];
    }

How to use?

This package allows you to define field sizes for detail, update or resource creation pages with tailwind CSS classes.

Like I want

You can use the size method on your field to add a meta property for each page. All Tailwind fluid classes for size can be used. See https://tailwindcss.com/docs/width/#fluid-width

Where I want

If you don't want to change the size of fields on each page, you can use methods to filter the effect:

  • sizeOnCreating
  • sizeOnUpdating
  • sizeOnForms
  • sizeOnDetail

Stacked or not stacked...

Automatically, with the default configuration, the field labels are stacked. If you don't want this, you can use the stacked method with a parameter value of false. As for previous point, you can do it wherever you want with:

  • stackedOnCreating
  • stackedOnUpdating
  • stackedOnForms
  • stackedOnDetail

Damn ! There is a bottom border

On the detail page, Nova automatically remove its lower border for the last field. In this package, it's not possible to calculate the last field, so you can delete it yourself. You can use these methods:

  • removeBottomBorderOnCreating
  • removeBottomBorderOnUpdating
  • removeBottomBorderOnForms
  • removeBottomBorderOnDetail

Example

This code uses the simplest method of configuration::

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

        Gravatar::make()->maxWidth(50),

        Text::make('Name')
            ->size('w-1/3')
            ->sortable()
            ->rules('required', 'max:255'),

        Text::make('Email')
            ->size('w-1/3')
            ->sortable()
            ->rules('required', 'email', 'max:254')
            ->creationRules('unique:users,email')
            ->updateRules('unique:users,email,{{resourceId}}'),
        Password::make('Password')
            ->size('w-1/3') // Only on forms, because we use onlyOnForms method with
            ->onlyOnForms()
            ->creationRules('required', 'string', 'min:8')
            ->updateRules('nullable', 'string', 'min:8'),
    ];
}

In this previous example, sizes are ok in forms pages but not in detail pages. This code presents several configurations depending on the context and uses different methods

/**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            Gravatar::make()->maxWidth(50),

            Text::make('Name')

                ->sizeOnDetail('w-1/2')
                ->stackedOnDetail(false)

                ->sizeOnForms('w-1/3')

                ->sortable()
                ->rules('required', 'max:255'),

            Text::make('Email')

                ->sizeOnDetail('w-1/2')
                ->stackedOnDetail(false)

                ->sizeOnForms('w-1/3')

                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->creationRules('unique:users,email')
                ->updateRules('unique:users,email,{{resourceId}}'),
            Password::make('Password')
                ->size('w-1/3') // Only on forms, because we use onlyOnForms method with
                ->onlyOnForms()
                ->creationRules('required', 'string', 'min:8')
                ->updateRules('nullable', 'string', 'min:8'),

            Date::make('Created At')
                ->hideWhenCreating()
                ->size('w-1/2')
                ->stacked(false)
                ->stackedOnForms(true)
                ->removeBottomBorderOnForms(),
            Date::make('Updated At')
                ->hideWhenCreating()
                ->size('w-1/2')
                ->stacked(false)
                ->stackedOnForms(true)
                ->removeBottomBorderOnForms(),
            Badge::make('Status 1', function () {
                return 'info';
            })->size('w-1/6')->removeBottomBorder(),
            Badge::make('Status 2', function () {
                return 'success';
            })->size('w-1/6')->removeBottomBorder(),
            Badge::make('Status 3', function () {
                return 'warning';
            })->size('w-1/6')->removeBottomBorder(),
            Badge::make('Status 4', function () {
                return 'info';
            })->size('w-1/6')->removeBottomBorder(),
            Badge::make('Status 5', function () {
                return 'success';
            })->size('w-1/6')->removeBottomBorder(),
            Badge::make('Status 6', function () {
                return 'warning';
            })->size('w-1/6')->removeBottomBorder(),


        ];
    }

Play with default values

Do you want go fast to configure your app ? With the HasDefaultSize trait, you can use defined default values.

You can use this trait in each resource where you want or on the App\Nova\Resource file if you want have default values on each resource automatically.

You be able to define default values on several ways :

  • by defining their on config file
  • by creating different methods acting, as the case may be (detail, creating, updating) like this :
public function defaultFieldSize()
{
    return 'w-1/8';
}

Methods can be : defaultFieldSize,defaultFieldSizeOnDetail,defaultFieldSizeOnCreating,defaultFieldSizeOnUpdating.

Configuration

You can disable each "automatic" feature for each type of page with the nova-grid-system.php config file. You can define default sizes for every fields. To publish it, you can use this command:

php artisan vendor:publish --tag="nova-grid-system"

License

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

About

This package is inspired by a deleted package by Eduardo Geschonke https://github.com/jobcerto

codenco-dev/nova-grid-system 适用场景与选型建议

codenco-dev/nova-grid-system 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 350.71k 次下载、GitHub Stars 达 81, 最近一次更新时间为 2020 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nova」 「layout」 「grid」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 codenco-dev/nova-grid-system 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codenco-dev/nova-grid-system 我们能提供哪些服务?
定制开发 / 二次开发

基于 codenco-dev/nova-grid-system 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 81
  • Watchers: 5
  • Forks: 40
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-18