-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add payment method and transaction resources, localization, and seedi…
…ng functionality
- Loading branch information
Showing
20 changed files
with
609 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
laratransaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Err0r\Laratransaction\Database\Seeders; | ||
|
||
use \Err0r\Laratransaction\Enums\PaymentMethod as PaymentMethodEnum; | ||
use Err0r\Laratransaction\Models\PaymentMethod; | ||
use Illuminate\Database\Seeder; | ||
|
||
class PaymentMethodSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$records = collect(PaymentMethodEnum::cases())->map(fn ($status) => [ | ||
'slug' => $status->value, | ||
])->toArray(); | ||
|
||
$locales = collect(config('laratransaction.localization.active_locales')); | ||
foreach ($records as $key => $record) { | ||
$records[$key]['name'] = $locales->mapWithKeys(fn ($locale) => [ | ||
$locale => __('laratransaction::transaction.payment_method.' . $record['slug'], locale: $locale) | ||
])->toArray(); | ||
} | ||
|
||
foreach ($records as $record) { | ||
PaymentMethod::updateOrCreate( | ||
['slug' => $record['slug']], | ||
$record | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Err0r\Laratransaction\Database\Seeders; | ||
|
||
use \Err0r\Laratransaction\Enums\TransactionStatus as TransactionStatusEnum; | ||
use Err0r\Laratransaction\Models\TransactionStatus; | ||
use Illuminate\Database\Seeder; | ||
|
||
class TransactionStatusSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$records = collect(TransactionStatusEnum::cases())->map(fn ($status) => [ | ||
'slug' => $status->value, | ||
])->toArray(); | ||
|
||
$locales = collect(config('laratransaction.localization.active_locales')); | ||
foreach ($records as $key => $record) { | ||
$records[$key]['name'] = $locales->mapWithKeys(fn ($locale) => [ | ||
$locale => __('laratransaction::transaction.status.' . $record['slug'], locale: $locale) | ||
])->toArray(); | ||
} | ||
|
||
foreach ($records as $record) { | ||
TransactionStatus::updateOrCreate( | ||
['slug' => $record['slug']], | ||
$record | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Err0r\Laratransaction\Database\Seeders; | ||
|
||
use \Err0r\Laratransaction\Enums\TransactionType as TransactionTypeEnum; | ||
use Err0r\Laratransaction\Models\TransactionType; | ||
use Illuminate\Database\Seeder; | ||
|
||
class TransactionTypeSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$records = collect(TransactionTypeEnum::cases())->map(fn ($status) => [ | ||
'slug' => $status->value, | ||
])->toArray(); | ||
|
||
$locales = collect(config('laratransaction.localization.active_locales')); | ||
foreach ($records as $key => $record) { | ||
$records[$key]['name'] = $locales->mapWithKeys(fn ($locale) => [ | ||
$locale => __('laratransaction::transaction.type.' . $record['slug'], locale: $locale) | ||
])->toArray(); | ||
} | ||
|
||
foreach ($records as $record) { | ||
TransactionType::updateOrCreate( | ||
['slug' => $record['slug']], | ||
$record | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
return [ | ||
'status' => [ | ||
'pending' => 'قيد الانتظار', | ||
'completed' => 'تمت العملية', | ||
'failed' => 'فشلت العملية', | ||
'cancelled' => 'تم الإلغاء', | ||
], | ||
'type' => [ | ||
'payment' => 'دفع', | ||
'refund' => 'استرداد', | ||
], | ||
'payment_method' => [ | ||
'credit_card' => 'بطاقة ائتمان', | ||
'bank_transfer' => 'تحويل بنكي', | ||
'cash' => 'نقدي', | ||
'other' => 'آخر', | ||
], | ||
]; |
Oops, something went wrong.