Skip to content
Arbory is a flexible Laravel based CMS for custom multilingual web development
PHP JavaScript CSS HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Jul 4, 2018
config
database Change redirect permanent bool to status select option Jan 31, 2019
resources Added translations for redirect page Jan 31, 2019
routes Bugfix of LFM response type: case of unsuccessful upload Jul 27, 2018
src Added translations for redirect page Jan 31, 2019
stubs
tests Implement element tests Aug 25, 2017
.codeclimate.yml Added Code Climate configuration Feb 29, 2016
.coveralls.yml
.gitignore Added code coverage reports Apr 19, 2017
.travis.yml Remove PHP 7.0 support Mar 20, 2018
LICENSE Add license Jul 4, 2018
README.md Replace outdated TODO with forthcoming roadmap information. Close #93 Dec 19, 2018
composer.json Disable pagination to export all items + use search conditions to fil… Jul 3, 2018
phpunit.xml Implement element tests Aug 25, 2017
webpack.mix.js Do not override webpack resolve config from Arbory webpack configuration Mar 26, 2018

README.md

Packagist Scrutinizer Code Quality Build Status Coverage Status

Installation

Create new Laravel project

composer create-project --prefer-dist laravel/laravel my-project "5.6.*"

Go to project root

cd my-project

Require Arbory package

composer require arbory/arbory "0.2.*"

Fill in database info

vi .env

Run installer and follow instructions

php artisan arbory:install

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'
            ]
        ]
    ],
]

Generators

Quick generator

php artisan arbory:generate {type?} {--T|table=}

Generators available for

  • Model
  • Page
  • Controller
  • View
  • AdminController - appends a new route to routes/admin.php

Verbose Generator

php artisan arbory:generator

Coding style

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:

Development

(Roadmap in progress)

You can’t perform that action at this time.