FilamentF
Filament10mo ago
mithyy

The code that works locally does not work in production

Hello, when I add the following code to my table, it always resets to the default state. It works fine locally, but in production, it always defaults.

I am using the same database.

Is there anyone who can help with solving this problem?

// Table column
return $table->columns([
    Tables\Columns\TextColumn::make("admin_approval")
        ->label("Stok Onayı")
        ->color(
            fn($state) => match ($state) {
                0 => "warning",
                1 => "success",
                default => "default",
            }
        )
        ->formatStateUsing(
            fn($state) => match ($state) {
                0 => "false text",
                1 => "true text",
                default => "default text",
            }
        )
        ->sortable()
        ->badge(),
]);

// Migration 
$table->boolean('admin_approval')->default(0)->after('status');

// MySql query
mysql> SELECT DISTINCT admin_approval FROM orders;
+----------------+
| admin_approval |
+----------------+
|              0 |
|              1 |
+----------------+

// laravel.log
[2025-03-11 10:30:29] production.ERROR: Unhandled match case '0' (View: /home/.../app/Filament/Pages/OrderList.php:175)
[previous exception] [object] (UnhandledMatchError(code: 0): Unhandled match case '0' at /home/.../public_html/app/Filament/Pages/OrderList.php:175)
Solution
I tried everything. As a result, the problem was solved when I used it with intval($state)
Was this page helpful?