A Nova field for Laraberg.
Dependency | Minimum version |
---|---|
PHP | 8.1 |
Laravel Nova | 4.35 |
Install via Composer:
composer require van-ons/laraberg-nova
Publish Laraberg files:
php artisan vendor:publish --provider="VanOns\Laraberg\LarabergServiceProvider"
Laraberg provides a CSS file that should be present on the page you want to render content on:
<link rel="stylesheet" href="{{ asset('vendor/laraberg/css/laraberg.css') }}">
Simply register the field in your Resource:
LarabergNova::make(__('Content'), 'content')
Add the RendersContent
trait to your model. And optionally define the
$contentColumn
property to point to the column that holds your Laraberg
content, this defaults to content
.
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use VanOns\Laraberg\Traits\RendersContent;
class Post extends Model
{
use HasFactory, RendersContent;
protected $contentColumn = 'content';
...
}
Call the render method on your model in a template:
{!! $model->render() !!}
The field has a few options you can configure.
You can customize the height of the editor:
LarabergNova::make(__('Content'), 'content')->height(600)
You can enable uploading attachments:
LarabergNova::make(__('Content'), 'content')->withFiles('public')
You will need to add the following migration to make this work:
Schema::create('laraberg_nova_pending_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('draft_id')->index();
$table->string('attachment');
$table->string('disk');
$table->timestamps();
});
Schema::create('laraberg_nova_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('attachable_type');
$table->unsignedInteger('attachable_id');
$table->string('attachment');
$table->string('disk');
$table->string('url')->index();
$table->timestamps();
$table->index(['attachable_type', 'attachable_id']);
});
Please see contributing for more information about how you can contribute.
Please see changelog for more information about what has changed recently.
Please see upgrading for more information about how to upgrade.
Please see security for more information about how we deal with security.
We would like to thank the following contributors for their contributions to this project:
The scripts and documentation in this project are released under the MIT License.