FilamentF
Filament2y ago
vas

update related model value

class Order extends Model
{
    protected $fillable = [
        'user_id',
        'payment_gateway',
        'session_id',
        'amount',
        'status',
    ];
    public function payment()
    {
        return $this->hasOne(Payment::class);
    }
}



class Payment extends Model
{

    protected $fillable = [
        'order_id',
        'amount',
        'status',
    ];

    public function order()
    {
        return $this->belongsTo(Order::class);
    }
}


class PaymentResource extends Resource
{
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
      
                Forms\Components\Select::make('status')
                    ->required()
                    ->options([
                        'pending' => PaymentStatusEnum::PENDING->value,
                        'paid' => PaymentStatusEnum::PAID->value,
                        'declined' => PaymentStatusEnum::DECLINED->value,
                        'failed' => PaymentStatusEnum::FAILED->value
                    ])->label('Stare'),



    }
}


any way to update the orders status to paid when selecting the payment as paid ? thanks
Was this page helpful?