When I save a Bard field the contents of the field in the edit screen is still json.
'resources' => [
\App\Models\MyModel::class => [
'name' => 'My Model',
'hidden' => true,
// 'icon' => '',
'blueprint' => [
'sections' => [
'main' => [
'fields' => [
[
'handle' => 'title',
'field' => [
'type' => 'text',
'validate' => 'required',
],
],
[
'handle' => 'body',
'field' => [
'type' => 'markdown',
'validate' => '',
],
],
[
'handle' => 'images',
'field' => [
'type' => 'assets',
'container' => 'assets',
'validate' => '',
],
],
[
'handle' => 'bard_content',
'field' => [
'always_show_set_button' => false,
'buttons' => [
'h2',
'h3',
'bold',
'italic',
'unorderedlist',
'orderedlist',
'removeformat',
'quote',
'anchor',
'image',
'table',
],
'save_html' => false,
'toolbar_mode' => 'fixed',
'link_noopener' => false,
'link_noreferrer' => false,
'target_blank' => false,
'reading_time' => false,
'fullscreen' => true,
'allow_source' => true,
'enable_input_rules' => true,
'enable_paste_rules' => true,
'display' => 'Standard Bard Field',
'type' => 'bard',
'icon' => 'bard',
'listable' => 'hidden',
],
],
],
],
],
],
'listing' => [
'columns' => [
'title',
],
'sort' => [
'column' => 'title',
'direction' => 'asc',
],
]
],
Schema::create('my_models', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('body')->nullable();
$table->json('images')->nullable();
$table->json('bard_content')->nullable();
$table->timestamps();
});
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MyModel extends Model
{
use HasFactory;
// protected $guarded = [];
protected $casts = [
'bard_content' => 'json',
];
}