FusionCMS is currently in an open beta state and under heavy active development.

Extensions

FusionCMS makes it easy to extend your Models with Fieldsets; we call these Extensions. Extended data is stored separately within its own table, but is just as easily accessible through your Models.

How extensions works

Getting Started

To get started, add the Fusion\Concerns\HasExtension trait to the Model file you wish to extend. The trait will include helper methods for pulling the extending Field data.

<?php

namespace Modules\Acme\Models;

use Fusion\Concerns\HasExtension;
use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    use HasExtension;

    ...
}

Next, run the fusion:sync command to register your Extension(s). This command will generate the necessary storage for storing the extending fields.

php artisan fusion:sync

Assigning a Fieldset

You should now see your Model listed in the Configure > Extensions interface where you can assign a Fieldset. This will generate the extending Fields.

Extensions overview page

Retrieving Fields

You can access the Fieldset and Fields, respectively:

  // Returns \Fusion\Models\Fieldset
  $fieldset = $model->fieldset;

  // Returns Collection of \Fusion\Models\Field
  $fields   = $model->fields;

Saving

HasExtension registers a saved event listener that will listen for Model events for saving the extending Fieldset.

Important: Laravel's Model Events only fire if the Model recieves an update, therefore it may be necessary to at least run $model->touch() for every PATCH request to assure is fired.

Have questions?

We're always happy to help with code or other questions you might have. Contact support or chat live with us on Discord.

Last edited on Monday, April 27, 2020 (3 years ago)