cubesystems / leaf
Administration interface for Laravel
Installs: 282
Dependents: 0
Suggesters: 0
Security: 0
Stars: 46
Watchers: 17
Forks: 32
Open Issues: 2
Requires
- php: ^8.2|^8.3
- ext-json: *
- arbory/translation: ^2
- astrotomic/laravel-translatable: ^11.6
- baum/baum: 3.x-dev
- cartalyst/sentinel: 8.x-dev
- doctrine/dbal: ^3.8
- laragear/two-factor: ^2.0
- laravel/framework: ^11.0
- maatwebsite/excel: ^3.1
- spatie/laravel-glide: ^3.8
- spatie/laravel-sluggable: ^3.6
- unisharp/laravel-filemanager: ^2.9
Requires (Dev)
- mockery/mockery: ^1.6
- orchestra/testbench-core: ^8
- php-coveralls/php-coveralls: ^2.7
- phpunit/phpunit: ^10
- dev-master
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- v3.x-dev
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- 2.3.10
- 2.3.9
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.x-dev
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.x-dev
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0
- 0.3.x-dev
- 0.2.19
- 0.2.18
- 0.2.17
- 0.2.16
- 0.2.15
- 0.2.14
- 0.2.13
- 0.2.12
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.x-dev
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-dependabot/npm_and_yarn/nanoid-3.3.8
- dev-dependabot/composer/phpoffice/phpspreadsheet-1.29.6
- dev-dependabot/composer/league/commonmark-2.6.0
- dev-3-stable
- dev-dependabot/composer/phpoffice/phpspreadsheet-1.29.4
- dev-2fa-toggle
- dev-2.3-stable
- dev-laravel9
- dev-2.0-stable
- dev-fix-select-pagination-with-filters
- dev-analysis-5ZrkWy
- dev-1.1-stable
- dev-1.0-stable
- dev-0.4-laravel-6
- dev-1.0-rc1
This package is auto-updated.
Last update: 2024-12-10 07:49:44 UTC
README
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:
- JS - https://github.com/airbnb/javascript
- CSS / SASS - https://github.com/airbnb/css