Skip to content


Default relations

By default, the OFFLINE\Boxes\Models\Box model has four relations defined:

attachOnefile, image
attachManyfiles, images

You can use these in your Box partials without any further changes.

Additional relations

You can use October's extend method to add additional relations to the default OFFLINE\Boxes\Models\Box model.

To add new relations to the Box model, use the following code in your app/Provider.php's boot method:

class Provider extends AppBase
    public function boot()
        \OFFLINE\Boxes\Models\Box::extend(function (Box $box) {
            $box->attachOne['logo'] = File::class;
            $box->belongsToMany['persons'] = [
                'table' => '...',

            // Example to add additional repeater item relations.
            $box->hasMany['my_custom_repeater_items'] = [
                'key' => 'parent_id',
                'delete' => true,

Eager loading

Since your Box is rendered inside a loop, you will experience an N+1 query problem sooner or later.

To prevent this, an eagerLoad property can be defined in a Box config. Defined relations will automatically be eager-loaded by the plugin.

To eager load the relations from the example above, this Box config could be used:

handle: eager-loading-example
- logo
- persons