PHP code example of ironshark / laravel-extendable

1. Go to this page and download the library: Download ironshark/laravel-extendable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ironshark / laravel-extendable example snippets


'providers' => [
    IronShark\Extendable\ExtendableServiceProvider::class,
];

php artisan vendor:publish --provider="IronShark\Extendable\ExtendableServiceProvider"
php artisan migrate

class Article extends \Illuminate\Database\Eloquent\Model {
    use IronShark\Extendable\ModelTrait;
}

return [
    'App\Room' => [                                                     // model name
        'light' => [                                                    // field name
            'title' => 'Light',                                         // field title (can be used in views)
            'type' => \IronShark\Extendable\CustomFieldType::Radio,     // field type
            'options' => [                                              // possible values/labels
                0 => 'Off',
                1 => 'On'
            ],
            'default' => 1                                              // default value
        ]
    ]
];

$data = [
    'title' => 'Awesome Article!!!', // regular field
    'recomended' => 1                // custom filed     
];

$article = new Article();
$article->fill($data);
$article->save();

$article = Article::find(1);
$article->recomended->value; // 1
echo $article->recomended;   // 1