ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentโ€ข14mo agoโ€ข
3 replies
Matthew

JSON relationship column in table

I have a table with a JSON column, like this:
Schema::create('filament-latex', function (Blueprint $table) {
    $table->id();
    // ...
    $table->json('collaborators_id')->nullable();
    // ...
    $table->timestamps();
});
Schema::create('filament-latex', function (Blueprint $table) {
    $table->id();
    // ...
    $table->json('collaborators_id')->nullable();
    // ...
    $table->timestamps();
});

In my model, I cast it as an array:
protected $fillable = ['collaborators_id']; /// other columns omitted
protected $table = 'filament-latex';
protected $casts = [
    'collaborators_id' => 'array',
];
protected $fillable = ['collaborators_id']; /// other columns omitted
protected $table = 'filament-latex';
protected $casts = [
    'collaborators_id' => 'array',
];

And in my resource table,
TextColumn::make('collaborators')
    ->label('Collaborators')
    ->visible(! config('filament-latex.avatar-columns'))
    ->badge()
    ->color('info'),
TextColumn::make('collaborators')
    ->label('Collaborators')
    ->visible(! config('filament-latex.avatar-columns'))
    ->badge()
    ->color('info'),

Using tinker, the column is saved on my table like this:
collaborators_id: "["4","5"]",
collaborators_id: "["4","5"]",

How should I define my relationship such that the resource table shows the name of the users? I havent used relationships that much so Im a bit confused ๐Ÿ˜…
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel โ€ข Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Select Column relationship in Table.
FilamentFFilament / โ“โ”Šhelp
2y ago
Display relationship on table column
FilamentFFilament / โ“โ”Šhelp
3y ago
One column per relationship model in table
FilamentFFilament / โ“โ”Šhelp
3y ago
Table Column for json value
FilamentFFilament / โ“โ”Šhelp
3y ago