PHP code example of laradium / laradium-content

1. Go to this page and download the library: Download laradium/laradium-content 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/ */

    

laradium / laradium-content example snippets

 artisan vendor:publish --tag=laradium-content

'widgetConstructor' => \Laradium\Laradium\Content\Base\Fields\WidgetConstructor::class,

php artisan laradium:channel Blog



namespace App\Laradium\Channels;

use App\Models\Channels\Blog;
use Laradium\Laradium\Base\FieldSet;
use Laradium\Laradium\Content\Models\Page;

Class BlogChannel
{

    /**
     * @param FieldSet $set
     */
    public function fields(FieldSet $set)
    {
        $set->morphsTo(Blog::class, Page::class)->fields(function (FieldSet $set) {
            $set->text('author');
            $set->wysiwyg('content');
        })->morphName('content');

        $set->widgetConstructor();
    }
}



namespace App\Laradium\Widgets;

use App\Models\Widgets\Hiw;
use Laradium\Laradium\Base\FieldSet;
use Laradium\Laradium\Content\Base\AbstractWidget;

class HiwWidget extends AbstractWidget
{

    /**
     * @var string
     */
    protected $model = Hiw::class;

    /**
     * @var string
     */
    protected $view = 'widgets.HiwWidget';

    /**
     * @param FieldSet $set
     * @return mixed|void
     */
    public function fields(FieldSet $set)
    {
        $set->text('title')->translatable();
        $set->text('description')->translatable();
        $set->hasMany('items')->fields(function (FieldSet $set) {
            $set->text('title')->translatable();
            $set->text('description')->translatable();
        })->sortable('sequence_no');
    }
}