Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

randomuser123's avatar

General error: 1364 Field 'triptitle' doesn't have a default value in this form but i've casts as json for these columns and in database too

my code

                Repeater::make('tripplans')
                ->schema([
                    TextInput::make('triptitle')
                    ->required(),
                    TextInput::make('tripdesc')
                    ->required(),
                ])
                ->addActionLabel('Add Another Day')
                ->columns(2)
                ->columnSpan(2),
0 likes
9 replies
Tray2's avatar

It means that the value of that field is null or missing when it hits the database.

Tray2's avatar

@randomuser123 My guess is that you either spelled the field wrong, your validation fails, or you forgotten to set the fillable array in your model.

randomuser123's avatar

@Tray2 i've checked it like 5 times already. my model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Destination extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'title',
        'title_url',
        'country_id',
        'activity_id',
        'content',
        'image',
        'special_id',
        'highlights',
        'datefrom',
        'dateto',
        'videolink',
        'minage',
        'transportation_id',
        'duration',
        'address',
        'map',
        'price',
        'includes',
        'excludes',
        'triptitle',
        'tripdesc',
        'ispublished',
        'related', 
        'created_by',
    'updated_by',
    'deleted_by',
    'is_deleted',        
      ];


protected $casts = [
    'image' => 'json',
    'country_id' => 'json',
    'activity_id' => 'json',
    'highlights' => 'json',
    'triptitle' => 'json',
    'tripdesc' => 'json',
    'includes' => 'json',
    'datefrom' => 'date',
    'dateto' => 'date',
    'excludes' => 'json',
    'related' => 'json',
    'ispublished'=> 'boolean',

];


public function activity() : BelongsTo
{
    return $this->belongsTo(Activity::class);
}

public function country() : BelongsTo
{
    return $this->belongsTo(Country::class);
}
public function transportation() : BelongsTo
{
    return $this->belongsTo(Transportation::class);
}
public function special() : BelongsTo
{
    return $this->belongsTo(Special::class);
}

}

my db

 Schema::create('destinations', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->string('title_url')->unique();
            $table->json('activity_id');
            $table->json('special_id')->nullable();
            $table->json('country_id');
            $table->json('image');
            $table->text('content');
            $table->json('highlights');
            $table->date('datefrom')->nullable();
            $table->date('dateto')->nullable();
            $table->text('videolink')->nullable();
            $table->integer('minage');
            $table->json('transportation_id');
            $table->integer('duration');
            $table->string('address');
            $table->text('map');
            $table->integer('price');
            $table->json('includes');
            $table->json('excludes');
            $table->json('triptitle');
            $table->json('tripdesc');   
            $table->boolean('ispublished')->default(false);
            $table->json('related')->nullable();
            $table->unsignedInteger('created_by')->nullable();
            $table->unsignedInteger('updated_by')->nullable();
            $table->softDeletes();
            $table->unsignedSmallInteger('deleted_by')->nullable();
            $table->boolean('is_deleted')->nullable();
            $table->timestamps();
        });
randomuser123's avatar

@Tray2 this is my complete resource code

<?php

namespace App\Filament\Resources;

use App\Filament\Resources\DestinationResource\Pages;
use App\Filament\Resources\DestinationResource\RelationManagers;
use App\Models\Destination;
use Filament\Forms;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;

class DestinationResource extends Resource
{
    protected static ?string $model = Destination::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                //
                Section::make('Rate limiting')
                ->schema([
                TextInput::make('title')
                ->required(),
                TextInput::make('title_url')
                ->required()])
                ->columns(2),
                Section::make('Rate limiting2')
                ->icon('heroicon-m-shopping-bag')
                ->description('Prevent abuse by limiting the number of requests per period')
                ->schema([
                Select::make('activity_id')
                ->multiple()
                ->relationship(name: 'activity', titleAttribute: 'name')
                ->dehydrated()
                ->preload()
                ->createOptionForm([
                    Forms\Components\TextInput::make('name')
                        ->required(),
                    
                ]),
                Select::make('country_id')
                ->multiple()
                ->relationship(name: 'country', titleAttribute: 'name')
                ->dehydrated()
                ->preload(),
                Select::make('transportation_id')
                ->relationship(name: 'transportation', titleAttribute: 'name')
                ->preload()
                ->createOptionForm([
                    Forms\Components\TextInput::make('name')
                        ->required(),
                    
                ]),
                Select::make('special_id')
                ->relationship(name: 'special', titleAttribute: 'name')
                ->preload()
                ->createOptionForm([
                    Forms\Components\TextInput::make('name')
                        ->required(),
                    
                ])])
                ->aside(),
                RichEditor::make('content')
                ->columnSpan(2),
               
                Section::make('Rate limiting')
                ->schema([
                Repeater::make('highlights')
                ->simple(
                    TextInput::make('highlights')
                   
                    ->required(),
                ),

                FileUpload::make('image')
                ->directory('gallery')
                ->multiple()
                ->image()
                ->imageEditor()])
                ->columns(2),

                

                Section::make('Rate limiting')
                ->schema([
                Repeater::make('includes')
                ->simple(
                    TextInput::make('includes')
                    
                    ->required(),
                ),
                Repeater::make('excludes')
                ->simple(
                    TextInput::make('excludes')
                    ->required(),
                )])
                ->columns(2),
                Repeater::make('tripplans')
                ->schema([
                    TextInput::make('triptitle')
                    ->required(),
                    TextInput::make('tripdesc')
                    ->required(),
                ])
                ->addActionLabel('Add Another Day')
                ->columns(2)
                ->columnSpan(2),
                Section::make('Rate limiting')
                ->schema([
                DatePicker::make('datefrom'),
                DatePicker::make('dateto')])
                ->columns(2),
                Section::make('Rate limiting')
                ->schema([
                TextInput::make('videolink')
                ->required()
                ->columnSpan(2),
                
               
                TextInput::make('map')
                ->required()
                ->columnSpan(2),
                TextInput::make('address')
                ->required()]),

                Section::make('Rate limiting')
                ->schema([
                TextInput::make('minage')
                ->required()
                ->integer(),
                TextInput::make('duration')
                ->required()
                ->integer()])
                ->columns(2),

                 Section::make('Rate limiting')
                ->schema([
                TextInput::make('price')
                ->required()
                ->integer()]),

                Toggle::make('ispublished')
                ->inline()
                ->onIcon('heroicon-s-eye')
                ->offIcon('heroicon-s-pencil-square')
                ->onColor('success')
                ->offColor('danger')
                ->columnSpan(2),

                Select::make('related')
                ->multiple()
                ->options(Destination::all()->pluck('title', 'id'))
                ->dehydrated()
                ->preload(),





            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                //
            ])
            ->filters([
                Tables\Filters\TrashedFilter::make(),
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                    Tables\Actions\ForceDeleteBulkAction::make(),
                    Tables\Actions\RestoreBulkAction::make(),
                ]),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListDestinations::route('/'),
            'create' => Pages\CreateDestination::route('/create'),
            'edit' => Pages\EditDestination::route('/{record}/edit'),
        ];
    }

    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }
}

can you spot whats wrong with the triptitle and tripdesc cause the error is still there.it will be alright if i make them normal textinputs without repeater but i need the repeater.

Please or to participate in this conversation.