- Refactored cooperation workflow to include manual status transitions. - Implemented payment tracking with CooperationPayment model and PayAction. - Updated UpdateCooperationStatusCommand for automatic assignment and verification transitions. - Removed deprecated date columns (assignment_deadline, verification_deadline). - Enhanced Filament UI with new actions (Complete, Proceed to Payment, Pay). - Added CooperationSeeder for testing purposes.
71 lines
2.6 KiB
PHP
71 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Actions\Media;
|
|
|
|
use App\Enums\ApprovalStatus;
|
|
use App\Enums\CooperationStatus;
|
|
use App\Filament\Support\CheerfulNotification;
|
|
use App\Models\CooperationMedia;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Support\Enums\Width;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Support\RawJs;
|
|
|
|
class PayAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Bayar')
|
|
->icon(Heroicon::CreditCard)
|
|
->color('success')
|
|
->visible(fn (CooperationMedia $record): bool => $record->cooperation->status === CooperationStatus::PAYMENT && ! $record->payment()->exists() && $record->status === ApprovalStatus::ACCEPTED)
|
|
->schema([
|
|
TextInput::make('amount')
|
|
->label('Nominal Pembayaran')
|
|
->placeholder('1,000,000')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->mask(RawJs::make('$money($input)'))
|
|
->prefix('Rp'),
|
|
|
|
SpatieMediaLibraryFileUpload::make('payment_proof')
|
|
->label('Bukti Pembayaran')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['image/*'])
|
|
->maxSize(1024 * 3)
|
|
->collection('cooperations')
|
|
->customProperties(fn (): array => [
|
|
'feature' => 'cooperations',
|
|
'date' => now()->toDateString(),
|
|
'doc_type' => 'payment-proof',
|
|
])
|
|
->image()
|
|
->required(),
|
|
|
|
Textarea::make('description')
|
|
->label('Keterangan')
|
|
->placeholder('...')
|
|
->autocomplete(false),
|
|
])
|
|
->action(function (CooperationMedia $record, array $data): void {
|
|
$record->payment()->create([
|
|
'amount' => str_replace(['Rp ', ','], '', $data['amount']),
|
|
'description' => $data['description'],
|
|
'payment_date' => now(),
|
|
]);
|
|
|
|
CheerfulNotification::success(
|
|
'Pembayaran Berhasil! 💸✨',
|
|
"Pembayaran untuk {$record->partnerMedia->name} telah berhasil dicatat."
|
|
)->send();
|
|
})
|
|
->modalWidth(Width::Large);
|
|
}
|
|
}
|