Laravel package to handle content.

dev-main 2021-01-19 23:01 UTC

This package is auto-updated.

Last update: 2023-03-20 03:40:11 UTC


Don't use in production yet!

This package will be a companion to Form Components Pro.

Latest Version on Packagist run-tests Quality Score Total Downloads Buy us a tree


  • PHP 7.4+
  • Laravel 6.0 and higher


Defining pages:

use ProtoneMedia\LaravelContent\Fields\Html;
use ProtoneMedia\LaravelContent\Fields\Image;
use ProtoneMedia\LaravelContent\Fields\Text;
use ProtoneMedia\LaravelContent\Pages\Page;

class ContactPage extends Page
    public function fields(): array
        return [
            'title'    => new Text,
            'header'   => new Image,
            'contents' => new Html,

$field = new Html;
$field = Html::make();

$field = Html::make()
    ->addToRules([new NoJavascriptRule, new NoExternalHostsRule])  // optional
    ->beforeSaving(new HtmlPurifier), // optional

Create/update from Request:

$newPageModel = ContactPage::fromRequest()->validate()->saveToModel(new PageModel);

// from request:
$contactPage = ContactPage::fromRequest()
$contactPage = ContactPage::fromRequest($request);

// validation:

// save to database:
$contactPage->saveToModel($yourModel, 'field');


Fields as Eloquent Casts:

use ProtoneMedia\LaravelContent\Fields\Image;
use ProtoneMedia\LaravelContent\Fields\Markdown;

class BlogPost extends Model
    protected $casts = [
        'top_image' => Image::class,
        'contents' => Markdown::class,

Standalone fields:

$field = Markdown::fromInput(request('contents'))

    'contents' => $field->getValue()

Media fields can have a custom backend:

Image::setDefaultRepositoryResolver(function() {
    return new MediaLibraryRepository;

Fields can be used in Blade views:

{{ $page->image }}

Which is equal to:





We proudly support the community by developing Laravel packages and giving them away for free. Keeping track of issues and pull requests takes time, but we're happy to help! If this package saves you time or if you're relying on it professionally, please consider supporting the maintenance and development.


You can install the package via composer:

composer require protonemedia/laravel-content




composer test


Please see CHANGELOG for more information about what has changed recently.


Please see CONTRIBUTING for details.

Other Laravel packages

  • Laravel Analytics Event Tracking: Laravel package to easily send events to Google Analytics.
  • Laravel Blade On Demand: Laravel package to compile Blade templates in memory.
  • Laravel Eloquent Scope as Select: Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.
  • Laravel Cross Eloquent Search: Laravel package to search through multiple Eloquent models.
  • Laravel Eloquent Where Not: This Laravel package allows you to flip/invert an Eloquent scope, or really any query constraint.
  • Laravel FFMpeg: This package provides an integration with FFmpeg for Laravel. The storage of the files is handled by Laravel's Filesystem.
  • Laravel Form Components: Blade components to rapidly build forms with Tailwind CSS Custom Forms and Bootstrap 4. Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!
  • Laravel Mixins: A collection of Laravel goodies.
  • Laravel Paddle: API integration for Laravel with support for webhooks/events.
  • Laravel Verify New Email: This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.
  • Laravel WebDAV: WebDAV driver for Laravel's Filesystem.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.


This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.