Skip to content

Commit ada30d8

Browse files
committed
Added contact management page
1 parent 71bf8f3 commit ada30d8

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/Filament/Resources/ContactResource.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,19 @@ public static function table(Table $table): Table
9595
Tables\Columns\TextColumn::make('status')
9696
->label('Status')
9797
->badge()
98-
->formatStateUsing(static function (?ContactStatus $status): string {
98+
->formatStateUsing(static function ($status): string {
9999
if ($status === null) {
100100
return '';
101101
}
102102

103-
return Str::title($status->value);
103+
// If the state is an enum instance, use its value; otherwise assume string
104+
if (is_object($status) && method_exists($status, 'value')) {
105+
$value = $status->value;
106+
} else {
107+
$value = (string) $status;
108+
}
109+
110+
return Str::title($value);
104111
}),
105112
Tables\Columns\TextColumn::make('lists_count')
106113
->label('Lists')

app/Models/Contact.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function workspace(): BelongsTo
3030

3131
public function lists(): BelongsToMany
3232
{
33-
return $this->belongsToMany(ContactList::class, 'list_contact')
33+
return $this->belongsToMany(ContactList::class, 'list_contact', 'contact_id', 'list_id')
3434
->withPivot(['subscribed_at', 'unsubscribed_at', 'meta']);
3535
}
3636

app/Models/ContactList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function workspace(): BelongsTo
2525

2626
public function contacts(): BelongsToMany
2727
{
28-
return $this->belongsToMany(Contact::class, 'list_contact')
28+
return $this->belongsToMany(Contact::class, 'list_contact', 'list_id', 'contact_id')
2929
->withPivot(['subscribed_at', 'unsubscribed_at', 'meta']);
3030
}
3131
}

0 commit comments

Comments
 (0)