PHPackages                             dewsign/nova-repeater-blocks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dewsign/nova-repeater-blocks

ActivePackage

dewsign/nova-repeater-blocks
============================

Enable repeatable content blocks through Polymorphic relationships on Nova resources.

v1.9.1(4y ago)341.6k7[1 issues](https://github.com/dewsign/nova-repeater-blocks/issues)[1 PRs](https://github.com/dewsign/nova-repeater-blocks/pulls)9MITPHPPHP &gt;=7.0.0CI failing

Since Oct 18Pushed 4y ago3 watchersCompare

[ Source](https://github.com/dewsign/nova-repeater-blocks)[ Packagist](https://packagist.org/packages/dewsign/nova-repeater-blocks)[ RSS](/packages/dewsign-nova-repeater-blocks/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (8)Versions (52)Used By (9)

Repeater Blocks for Laravel Nova
================================

[](#repeater-blocks-for-laravel-nova)

Enable repeatable content blocks through Polymorphic relationships on Nova resources.

Installation
------------

[](#installation)

Install the repeater blocks package through composer

```
composer require dewsign/nova-repeater-blocks
```

Run the migrations. Note: This package uses a single table to manage all polymorphic repeater blocks so there is no need to modify any existing tables!

```
php artisan migrate
```

Nova UI
-------

[](#nova-ui)

For this readme we will use a basic Blog example where a Blog Post is generated from multiple Rich Text Editor style repeatable content blocks (e.g. Text, Image.)

First add the trait to your Model

```
// app/Post.php
use Dewsign\NovaRepeaterBlocks\Traits\HasRepeaterBlocks;

class Post extends Model {
    use HasRepeaterBlocks;
    ...
}
```

Then create a Resource to define the repeater blocks for this Model/Resource (e.g. Posts). This can be more generic if you are planning on sharing the same blocks on different models. Extend the base resource provided.

```
// app/Nova/PostRepeater.php

use App\Nova\RbText;
use Illuminate\Http\Request;
use Dewsign\NovaRepeaterBlocks\Fields\Repeater;

class PostRepeater extends Repeater
{
    // One or more Nova Resources which use this Repeater
    public static $morphTo = 'App\Nova\Post';

    // What type of repeater blocks should be made available
    public function types(Request $request)
    {
        return [
            RbText::class,
            RbImage::class,
        ];
    }
}
```

Now we need to create `RbText` and `RbImage`, both of which are just standard Nova Resources with an extra Trait. You are free to name them however you like and you can simply create them as you would any other Laravel Model and Resource.

```
php artisan make:model -m RbText
```

```
// app/RbText.php
