grizzlyware/aero-rich-additionals 问题修复 & 功能扩展

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

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

grizzlyware/aero-rich-additionals

最新稳定版本:v1.2.1

Composer 安装命令:

composer require grizzlyware/aero-rich-additionals

包简介

Allow recording structured additional attributes against models in Aero Commerce

README 文档

README

Grizzlyware

Rich Additionals for Aero Commerce

This package allows recording structured additional attributes against models in Aero Commerce.

image

Installation

You can install the package via Composer:

composer require grizzlyware/aero-rich-additionals

Usage

Rich attributes can be added to the following models (so far!):

  • Products
  • Categories
  • Pages
  • Shipping Methods

Pass the model class to the add or helper methods on the RichAdditionals facade, and then chain methods to configure the attribute, if required.

<?php

namespace App\Providers;

use Aero\Admin\Facades\Admin;
use Aero\Catalog\Models\Product;
use App\Enums\PaperSize;
use Grizzlyware\Aero\RichAdditionals\AttributeType;
use Grizzlyware\Aero\RichAdditionals\Facades\RichAdditionals;
use Illuminate\Support\ServiceProvider;

class RichAdditionalsProvider extends ServiceProvider
{
    public function boot(): void
    {
        // For performance, only register the additional attributes when the admin panel is booted
        Admin::booted(
            $this->registerAdditionalAttributes(...)
        );
    }

    private function registerAdditionalAttributes(): void
    {
        // Options generated from an enum class
        RichAdditionals::enum(
            'paper_size',
            Product::class,
            PaperSize::class,
        );

        // Free text
        RichAdditionals::add('nickname', Product::class)
            ->setAttributeLabel('Nickname')
            ->setRequired()
            ->setHelp('A nickname for the product')
        ;

        // Manually defined options
        RichAdditionals::add('color', Product::class, AttributeType::DROPDOWN)
            ->setHelp('The color of the product')
            ->setOptions([
                'red' => 'Red',
                'green' => 'Green',
                'blue' => 'Blue',
            ])
        ;

        // Custom validation rules
        RichAdditionals::add('sales_email', Product::class)
            ->setHelp('Email address of the sales manager for this product')
            ->setValidationRules(['email'])
        ;

        // Generate options with a callback
        RichAdditionals::add('aisle_number', Product::class, AttributeType::DROPDOWN)
            ->setHelp('Where is this product located in the store?')
            ->setOptions(fn() => array_combine(range(50, 100), range(50, 100)))
        ;
    }
}

Support

Please raise an issue on GitHub if you have any problems with this package.

Development of this package is sponsored by Grizzlyware.

Commercial support is available, please contact us for more information.

Security

If you discover any security related issues, please email a maintainer of this project, and do not raise an issue.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-02