PHPackages                             plank/contentable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. plank/contentable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plank/contentable
=================

Create dynamic pages using polymorphic relationships and special Module classes

v0.1.0(11mo ago)24.7k↑42.9%[2 PRs](https://github.com/plank/contentable/pulls)MITPHPPHP ^8.2CI passing

Since Nov 1Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/plank/contentable)[ Packagist](https://packagist.org/packages/plank/contentable)[ Docs](https://github.com/plank/contentable)[ RSS](/packages/plank-contentable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (12)Versions (19)Used By (0)

[![](art/contentable.png)](https://plank.co)

[![PHP Version Support](https://camo.githubusercontent.com/928ca892af4faf289107623c4ab34e4370635d01879baf9486d85dff93b02b77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706c616e6b2f636f6e74656e7461626c653f636f6c6f723d253233666165333730266c6162656c3d706870266c6f676f3d706870266c6f676f436f6c6f723d253233666666)](https://packagist.org/packages/plank/contentable)[![GitHub Workflow Status](https://camo.githubusercontent.com/18b902ccea7b81bf6fa10977b225118e48c21b7e8388350bc8c22ad7f778a01e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c616e6b2f636f6e74656e7461626c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e2626636f6c6f723d253233626663396264266c6162656c3d72756e2d7465737473266c6f676f3d676974687562266c6f676f436f6c6f723d253233666666)](https://github.com/plank/contentable/actions?query=workflow%3Arun-tests)[![](https://camo.githubusercontent.com/85f10f309bae407705a7b7368687cb4d377e2243f5bd5253db88722328d36aaf/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f706c616e6b2f636f6e74656e7461626c653f636f6c6f723d253233666639333736266c6162656c3d74657374253230636f766572616765266c6f676f3d636f64652d636c696d617465266c6f676f436f6c6f723d253233666666)](https://codeclimate.com/github/plank/contentable/test_coverage)[![](https://camo.githubusercontent.com/2038fde996a988e32fd19311ea6cfee8c2f55c6b39bd3bd3f6d6ba7af18253f7/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f706c616e6b2f636f6e74656e7461626c653f636f6c6f723d253233353238636666266c6162656c3d6d61696e7461696e61626c696c697479266c6f676f3d636f64652d636c696d617465266c6f676f436f6c6f723d253233666666)](https://codeclimate.com/github/plank/contentable/maintainability)

Laravel Contentable
===================

[](#laravel-contentable)

⚠️ This package is currently in development and is not ready for production use. ⚠️

This package allows for models to be built up dynamically by attaching `Content` to it. It's intended use is to allow for creating a module system that plays nicely with Laravel Nova (via Repeaters, or other block editing systems) to create user defined pages.

Considerations have been made to keep this package compatible with other packages in the Plank ecosystem such as [Snapshots](https://github.com/plank/snapshots). It also has been architected to allow for explicit linking between modules and other entities within an application.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Usage](#usage)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)
- [Security Vulnerabilities](#security-vulnerabilities)

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

[](#installation)

You can install the package via composer:

```
composer require plank/contentable
```

Quick Start
-----------

[](#quick-start)

Once the installation has completed, to begin using the package:

1. Add the `HasContent` trait and `Contentable` interface to any model you'd like to attach content too.
2. Add the `CanRender` trait and `Renderable` interface to any models that will act as "Modules".
3. Implement the missing `Renderable` interface methods, specifically the `renderHtml()` method. Optionally add a `$renderableFields` class property, listing all fields that should be accessed by the module.

Configuration
-------------

[](#configuration)

The package's configuration file is located at `config/contentable.php`. If you did not publish the config file during installation, you can publish the configuration file using the following command:

```
php artisan vendor:publish --tag=contentable-config
# Be sure to run any associated migrations
php artisan migrate
```

Usage
-----

[](#usage)

### Building a Module system

[](#building-a-module-system)

Contentable's main purpose is to ease the building of a page builder style experience while maintaining explicit relationships between `Renderable` models and any other arbitrary models within the application. This enables easily building things like "Callout" modules, that can link to a concrete record in the database.

#### Define Modules

[](#define-modules)

To take advantage of the above approach, any modules that are distinct from each other must be defined as their own models. Eg, you might define a simple "Text" module (that is, a section on a page that displays a title and body text) like so:

```
