After form submission, data insertion is blocked due to an array issue related to marked checkboxes

Could you help me with how to insert the options of the checkboxes already marked into the memberships table from the Filament form? However, I'm encountering an 'Array to string conversion' error View the attachments.
No description
No description
No description
Solution:
what is your column's name? you have added videos in the cast but using video_id in schema it should be video_id in casts too. (assuming the column name is video_id & column type text or json)...
Jump to solution
4 Replies
Sanchit Patil
Sanchit Patil14mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
No description
Leonel  López
Leonel LópezOP14mo ago
Yes I added this cast <?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\Relations\HasMany; class Membership extends Model { use HasFactory; protected $casts = [ 'videos' => 'array', ]; protected $fillable = ['user_id', 'video_id', 'abonnement_id', 'status']; public function users(): BelongsTo { return $this->BelongsTo(User::class);
} public function abonnements(): BelongsTo { return $this->BelongsTo(Abonnement::class);
} } And still 'Array to string conversion' error
Solution
Sanchit Patil
Sanchit Patil14mo ago
what is your column's name? you have added videos in the cast but using video_id in schema it should be video_id in casts too. (assuming the column name is video_id & column type text or json)
Leonel  López
Leonel LópezOP14mo ago
Fixed! You are right! Before, my column's name was 'integer'. Then I changed it to 'json' and it worked for insertion! Also, I'm using 'video_id' in the cast. Thanks for your help!
No description
Want results from more Discord servers?
Add your server