Feat: Adding Translations to Payment and Shipping Methods, removing unecessary shipping method fulfillment type
This commit is contained in:
@@ -12,6 +12,7 @@ use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Lunar\Admin\Support\Forms\Components\TranslatedText;
|
||||
use Modules\Core\Payment\Contracts\Configurable;
|
||||
use Modules\Core\Payment\Events\PaymentMethodsReordered;
|
||||
use Modules\Core\Payment\Filament\Resources\PaymentMethodResource\Pages\ListPaymentMethods;
|
||||
@@ -76,7 +77,7 @@ class PaymentMethodResource extends Resource
|
||||
->sortable(),
|
||||
TextColumn::make('name')
|
||||
->label('Name')
|
||||
->searchable(),
|
||||
->state(fn (PaymentMethod $record) => $record->translate('name')),
|
||||
TextColumn::make('type')
|
||||
->label('Type'),
|
||||
TextColumn::make('driver')
|
||||
@@ -124,10 +125,9 @@ class PaymentMethodResource extends Resource
|
||||
public static function getFormComponents(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('name')
|
||||
TranslatedText::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->required(),
|
||||
TextInput::make('type')
|
||||
->label('Type')
|
||||
->helperText('Machine-facing slug — stored on the cart/order, used by other code to identify this method. Cannot be changed once orders reference it.')
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Modules\Core\Payment\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Lunar\Base\Traits\HasTranslations;
|
||||
|
||||
/**
|
||||
* A merchant-configured payment method — the DB-instance layer, admin
|
||||
@@ -11,7 +12,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* shipping_methods table already has (see docs/payments.md):
|
||||
* - type: unique, machine-facing slug (Cart::meta['payment_method'],
|
||||
* ApplyPaymentMethodFee's lookup key, every Payment event's $type).
|
||||
* - name: admin-facing label.
|
||||
* - name: admin-facing label, locale-keyed JSON (e.g.
|
||||
* {"en": "Cash On Delivery", "el": "Αντικαταβολή"}) — same shape/
|
||||
* resolution as Product/Collection names (Lunar\Base\Traits\
|
||||
* HasTranslations), just applied directly to this column rather than
|
||||
* through attribute_data, since this is a merchant settings row, not
|
||||
* a catalog attribute. Rendered in Filament via Lunar's own
|
||||
* Lunar\Admin\Support\Forms\Components\TranslatedText — one input per
|
||||
* configured Language row, no bespoke translation UI. Resolve a
|
||||
* display string with $method->translate('name') (locale defaults to
|
||||
* app()->getLocale(), falling back to the store's default language).
|
||||
* - driver: the Modules\Core\Payment\Services\PaymentDriverRegistry key
|
||||
* — NOT the same as `type`, and not unique (two rows can share one
|
||||
* driver, e.g. two differently-named offline-style methods).
|
||||
@@ -28,12 +38,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
use HasTranslations;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'enabled' => 'boolean',
|
||||
'position' => 'integer',
|
||||
'driver_missing_at' => 'datetime',
|
||||
'name' => 'array',
|
||||
'data' => AsArrayObject::class,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user