Skip to content

LCM structure

Dmytro Kardava edited this page Jul 12, 2019 · 9 revisions

Modifier model example

<?php

class YourModifier 
{
    private $leaf_type = 'pages'; // string or array
    
    private $prefix = 'seo';

    private $fields = [
        'parent' => [
            'type' => 'relation',
            'relation_type' => 'belongsTo',
            'leaf_type' => 'page',
            'nullable' => true,
        ],
        'template' => [
            'type' => 'template',
            'nullable' => true
        ],
        'thumbnail' => [
            'type' => 'file',
            'nullable' => true,
        ],
        'page_bg' => [
            'type' => 'file',
            'nullable' => true
        ],
    ];

    private $bread = [
        'browse' => [
            'table_columns' => 'title',
        ],
    ];

    private $conditions = [
        [
            'parameter' => 'page_template',
            'operator' => 'is',
            'value' => 'custom_template',
        ]
    ];
 }

Field structure

'field_slug' => [
    'type' => 'relation',           // input type, options: 'relation', 'text', 'number',
                                    // 'select', 'select-multiple', 'checkbox', 'radio',
                                    // 'password', 'file', 'file-multiple', 'date',
                                    // 'datetime-local', 'time', 'month', 'color'
    'relation_type' => 'belongsTo', // relation type, only required if 'type' is 'relation'
                                    // ['belongsTo', 'belongsToMany']

    'leaf_type' => 'page',          // id or name of leaf type that is used for relation

    'options' => [                  // (optional) array of options, goes with specific inputs i.e. 'select'
        'option_1', 'option_2',
    ],

    'default' => 'default_value',   // (optional) default value to use if user doesn't provide anything

    'nullable' => true,             // (optional) whether the field is nullable or not
    //!!!  if nullable is not set or is false and there is no default value,  !!!\\
    //!!!  field is considered to be required                                 !!!\\
],
Clone this wiki locally