arbory/arbory 问题修复 & 功能扩展

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

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

arbory/arbory

最新稳定版本:4.1.21

Composer 安装命令:

composer require arbory/arbory

包简介

Administration interface for Laravel

README 文档

README

Packagist Scrutinizer Code Quality Build Status StyleCI Coverage Status

Installation

Create new Laravel project

composer create-project --prefer-dist laravel/laravel=8.0 my-project

Go to project root

cd my-project

Require Arbory package

composer require arbory/arbory

Fill in database info

vi .env

Run installer and follow instructions

php artisan arbory:install

That's it!

Visit http://localhost/admin

Usage

Registering new pages

Page::register( App\Pages\TextPage::class )
    ->fields( function( FieldSet $fieldSet )
    {
        $fieldSet->add( new Arbory\Base\Admin\Form\Fields\Richtext( 'text' ) );
    } )
    ->routes( function()
    {
        Route::get( '/', App\Http\Controllers\TextPageController::class . '@index' )->name( 'index' );
    } );

Registering new admin modules

Admin::modules()->register(  App\Http\Controllers\Admin\TextController::class );

Working with nodes

The node repository is used to ensure that the website only displays active nodes to the user

$currentNode = app( Arbory\Base\Nodes\Node::class );
$nodes = app( Arbory\Base\Repositories\NodesRepository::class ); 

// returns only the active children of the current node
$nodes->findUnder( $currentNode );

Validation

Validation rules can be attached to any field, like so

$form->addField( new Text( 'title' ) )->setRules( 'required' );

Validating translations

$form->addField( new Translatable( ( new Text( 'title' ) )->rules( 'required' ) ) );

Custom validators

  • arbory_require_one_localized - at least one translation exists for this field
  • arbory_file_required - file has been uploaded or is being passed in request

Fields

Object Relation

Create a relation to another model

new Arbory\Base\Admin\Form\Fields\ObjectRelation( 'field_name', Arbory\Base\Nodes\Node::class );

To limit the amount of relations the user can select a third argument can be passed. Relation fields limited to a single model will be rendered more compactly.

new ObjectRelation( 'field_name', Arbory\Base\Nodes\Node::class, 1 ); // single relation, compact view 
new ObjectRelation( 'field_name', Arbory\Base\Nodes\Node::class, 10 ); 

An optional depth parameter can be passed (automatically set for the node relation) which adds visual nesting to the field items

( new ObjectRelation( 'field_name', Arbory\Base\Nodes\Node::class ) )->setIndentAttribute( 'depth' );

Items can be grouped by an attribute

$getName = function( \Arbory\Base\Nodes\Node $model ) 
{
    return class_basename( $model->content_type );
};

( new ObjectRelation( 'field_name', Arbory\Base\Nodes\Node::class ) )->groupBy( 'content_type', $getName );

Settings

Register a setting (with optional nesting) and retrieve it

return [
    'my_letter' => [
        'to' => 'a friend',
        'subject' => 'Hello!'
    ]
]
Settings::has('my_letter.to'); // true
Settings::get('my_letter.to'); // "a friend"

Defining a field type

return [
    'my_setting_key' => [
        'value' => 'My setting value',
        'type' => Arbory\Base\Admin\Form\Fields\CompactRichtext::class
    ],
]

File settings

return [
    'my_setting_file' => [
        'value' => null,
        'type' => Arbory\Base\Admin\Form\Fields\ArboryFile::class
    ],
    'my_setting_image' => [
        'value' => null,
        'type' => Arbory\Base\Admin\Form\Fields\ArboryImage::class
    ],
]

Translatable settings

return [
    'hello' => [
        'type' => Arbory\Base\Admin\Form\Fields\Translatable::class,
        'value' => [
            'type' => Arbory\Base\Admin\Form\Fields\CompactRichtext::class,
            'value' => [
                'en' => 'Hello',
                'lv' => 'Sveiks'
            ]
        ]
    ],
]

Generate admin User

php artisan arbory:create-user 

Contributing

To submit SCSS/Js changes you must rebuild dist directory containing compiled assets. Run npm run prod to do that.

Coding style

Use PSR-1/2

JS

We use airbnb coding style for both JS and SASS (links below).

To install the built-in inspections for PHPStorm, follow these instructions: https://www.themarketingtechnologist.co/how-to-get-airbnbs-javascript-code-style-working-in-webstorm/

Note!

When specifying JSCS package in the configuration window, it has to be installed locally (within the project). Global installation will not work (PHPStorm installs packages globally).

Customization

Rules can be modified either in separate files (.jscsrc or .jscs.json in project's root directory) or project's package.json file (jscsConfig section).

Links:

统计信息

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

GitHub 信息

  • Stars: 46
  • Watchers: 15
  • Forks: 32
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-25