Enhance CardOrder model and SMS functionality
- Added unique ID generation and SMS notification upon CardOrder creation. - Updated CardOrdersTable to default sort by creation date. - Implemented logging for SMS sending in SmsRepository for better debugging.
This commit is contained in:
@@ -26,6 +26,7 @@ class CardOrdersTable
|
|||||||
->modifyQueryUsing(function (Builder $query) {
|
->modifyQueryUsing(function (Builder $query) {
|
||||||
DefaultQueryForResourceIndexRepository::make($query);
|
DefaultQueryForResourceIndexRepository::make($query);
|
||||||
})
|
})
|
||||||
|
->defaultSort('created_at', 'desc')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('unique_id')
|
TextColumn::make('unique_id')
|
||||||
->label(__('ID'))
|
->label(__('ID'))
|
||||||
|
|||||||
@@ -109,7 +109,16 @@ class CardOrder extends Model implements BelongsToBranch, HasStatus
|
|||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
static::creating(LoanOrderRepository::creating());
|
static::creating(LoanOrderRepository::creating());
|
||||||
static::created(LoanOrderRepository::created());
|
|
||||||
|
static::created(function ($model) {
|
||||||
|
$uniqueId = LoanOrderRepository::generateUniqueId($model);
|
||||||
|
$model->update(['unique_id' => $uniqueId]);
|
||||||
|
|
||||||
|
sendSMS(
|
||||||
|
$model->phone,
|
||||||
|
__('module.card-order::base.card_order_created', ['order_id' => $uniqueId])
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
5
app/Modules/CardOrder/Resources/Lang/tk/base.php
Normal file
5
app/Modules/CardOrder/Resources/Lang/tk/base.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'card_order_created' => 'Kart sargydyňyz :order_id belgi bilen hasaba alyndy. Sargydy tassyklamak üçin operatorymyz habarlaşar.',
|
||||||
|
];
|
||||||
@@ -15,6 +15,7 @@ class SmsRepository
|
|||||||
public static function sendSMS(string|int $phone, string|int $message): mixed
|
public static function sendSMS(string|int $phone, string|int $message): mixed
|
||||||
{
|
{
|
||||||
if (app()->environment('local')) {
|
if (app()->environment('local')) {
|
||||||
|
info('Sending SMS to ' . $phone . ' with message: ' . $message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user