Skip to content

Commit

Permalink
code formatted and optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Feb 26, 2024
1 parent de28a2f commit 4de552e
Show file tree
Hide file tree
Showing 67 changed files with 1,931 additions and 1,855 deletions.
19 changes: 13 additions & 6 deletions config/remit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?php

// config for Fintech/Remit
use Fintech\Remit\Models\BankTransfer;
use Fintech\Remit\Models\CashPickup;
use Fintech\Remit\Models\WalletTransfer;
use Fintech\Remit\Repositories\Eloquent\BankTransferRepository;
use Fintech\Remit\Repositories\Eloquent\CashPickupRepository;
use Fintech\Remit\Repositories\Eloquent\WalletTransferRepository;

return [

/*
Expand Down Expand Up @@ -31,7 +38,7 @@
|
| This value will be used to across system where model is needed
*/
'bank_transfer_model' => \Fintech\Remit\Models\BankTransfer::class,
'bank_transfer_model' => BankTransfer::class,

/*
|--------------------------------------------------------------------------
Expand All @@ -40,7 +47,7 @@
|
| This value will be used to across system where model is needed
*/
'cash_pickup_model' => \Fintech\Remit\Models\CashPickup::class,
'cash_pickup_model' => CashPickup::class,

/*
|--------------------------------------------------------------------------
Expand All @@ -49,7 +56,7 @@
|
| This value will be used to across system where model is needed
*/
'wallet_transfer_model' => \Fintech\Remit\Models\WalletTransfer::class,
'wallet_transfer_model' => WalletTransfer::class,

//** Model Config Point Do not Remove **//

Expand Down Expand Up @@ -151,11 +158,11 @@
*/

'repositories' => [
\Fintech\Remit\Interfaces\BankTransferRepository::class => \Fintech\Remit\Repositories\Eloquent\BankTransferRepository::class,
\Fintech\Remit\Interfaces\BankTransferRepository::class => BankTransferRepository::class,

\Fintech\Remit\Interfaces\CashPickupRepository::class => \Fintech\Remit\Repositories\Eloquent\CashPickupRepository::class,
\Fintech\Remit\Interfaces\CashPickupRepository::class => CashPickupRepository::class,

\Fintech\Remit\Interfaces\WalletTransferRepository::class => \Fintech\Remit\Repositories\Eloquent\WalletTransferRepository::class,
\Fintech\Remit\Interfaces\WalletTransferRepository::class => WalletTransferRepository::class,

//** Repository Binding Config Point Do not Remove **//
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

use Fintech\Core\Enums\Transaction\OrderStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
if (! Schema::hasTable('orders')) {
if (!Schema::hasTable('orders')) {
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->foreignId('source_country_id')->nullable();
Expand All @@ -31,7 +31,7 @@ public function up(): void
$table->longText('notes')->nullable();
$table->boolean('is_refunded')->nullable()->default(false)->comment('if money has refunded');
$table->json('order_data')->nullable();
$table->string('status')->default(\Fintech\Core\Enums\Transaction\OrderStatus::Processing->value);
$table->string('status')->default(OrderStatus::Processing->value);
$table->foreignId('creator_id')->nullable();
$table->foreignId('editor_id')->nullable();
$table->foreignId('destroyer_id')->nullable();
Expand Down
3 changes: 2 additions & 1 deletion resources/img/service/logo_svg/mbs_m_cash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/img/service_vendor/logo_svg/citybank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 12 additions & 6 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

use Fintech\Core\Facades\Core;
use Fintech\Remit\Http\Controllers\AssignVendorController;
use Fintech\Remit\Http\Controllers\BankTransferController;
use Fintech\Remit\Http\Controllers\CashPickupController;
use Fintech\Remit\Http\Controllers\WalletTransferController;
use Fintech\Remit\Http\Controllers\WalletVerificationController;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;

Expand All @@ -17,16 +23,16 @@
Route::prefix('remit')->name('remit.')
->middleware(config('fintech.auth.middleware'))
->group(function () {
if (\Fintech\Core\Facades\Core::packageExists('Transaction')) {
if (Core::packageExists('Transaction')) {
Route::get('assignable-vendors/{order_id}',
[\Fintech\Remit\Http\Controllers\AssignVendorController::class, 'available'])
[AssignVendorController::class, 'available'])
->name('assignable-vendors.available');
}
Route::apiResource('bank-transfers', \Fintech\Remit\Http\Controllers\BankTransferController::class)->except('update', 'destroy');
Route::apiResource('cash-pickups', \Fintech\Remit\Http\Controllers\CashPickupController::class)->except('update', 'destroy');
Route::apiResource('wallet-transfers', \Fintech\Remit\Http\Controllers\WalletTransferController::class)->except('update', 'destroy');
Route::apiResource('bank-transfers', BankTransferController::class)->except('update', 'destroy');
Route::apiResource('cash-pickups', CashPickupController::class)->except('update', 'destroy');
Route::apiResource('wallet-transfers', WalletTransferController::class)->except('update', 'destroy');

Route::post('wallet-verification', \Fintech\Remit\Http\Controllers\WalletVerificationController::class)->name('wallet-verification');
Route::post('wallet-verification', WalletVerificationController::class)->name('wallet-verification');

//DO NOT REMOVE THIS LINE//
});
Expand Down
97 changes: 49 additions & 48 deletions src/Abstracts/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;
use JsonException;

abstract class Wrapper implements Arrayable, ArrayAccess, Jsonable
{
Expand All @@ -30,29 +31,35 @@ public function __toString()
return $this->toJson();
}

public function __isset($name)
public function toJson($options = 0): bool|string
{
return $this->offsetExists($name);
$json = json_encode($this->attributes, $options);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new JsonException(json_last_error_msg());
}

return $json;
}

public function __get($name)
public function __isset($name)
{
return $this->offsetGet($name);
return $this->offsetExists($name);
}

public function __set($name, $value)
public function offsetExists($offset): bool
{
$this->offsetSet($name, $value);
return isset($this->attributes[$offset]) || isset($this->extra[$offset]);
}

public function __unset($name)
public function __get($name)
{
$this->offsetUnset($name);
return $this->offsetGet($name);
}

public function offsetExists($offset): bool
public function __set($name, $value)
{
return isset($this->attributes[$offset]) || isset($this->extra[$offset]);
$this->offsetSet($name, $value);
}

public function offsetGet($offset)
Expand All @@ -75,38 +82,6 @@ public function offsetSet($offset, $value): void
$this->resolveCasts();
}

public function offsetUnset($offset): void
{
if (array_key_exists($offset, $this->attributes)) {
unset($this->attributes[$offset]);
}

if (array_key_exists($offset, $this->extra)) {
unset($this->extra[$offset]);
}
}

public function toRaw()
{
return $this->raw;
}

public function toArray(): array
{
return array_merge($this->attributes, $this->extra);
}

public function toJson($options = 0): bool|string
{
$json = json_encode($this->attributes, $options);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new \JsonException(json_last_error_msg());
}

return $json;
}

public function resolveCasts(): void
{
foreach ($this->casts as $field => $cast) {
Expand Down Expand Up @@ -135,15 +110,15 @@ private function convertValue($type, $value): mixed
return $value == 'true';
}

return (bool) $value;
return (bool)$value;

case 'float' :
case 'double' :
case 'decimal' :
return (float) $value;
return (float)$value;

case 'integer' :
return (int) $value;
return (int)$value;

case 'array' :
return Arr::wrap($value);
Expand All @@ -152,14 +127,40 @@ private function convertValue($type, $value): mixed
case 'date':
return Carbon::parse($value);

// case 'money' :
// return Money::parse($value);
// case 'money' :
// return Money::parse($value);

case 'string' :
return (string) $value;
return (string)$value;

default:
return $value;
}
}

public function __unset($name)
{
$this->offsetUnset($name);
}

public function offsetUnset($offset): void
{
if (array_key_exists($offset, $this->attributes)) {
unset($this->attributes[$offset]);
}

if (array_key_exists($offset, $this->extra)) {
unset($this->extra[$offset]);
}
}

public function toRaw()
{
return $this->raw;
}

public function toArray(): array
{
return array_merge($this->attributes, $this->extra);
}
}
5 changes: 3 additions & 2 deletions src/Commands/AgraniInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fintech\Remit\Commands;

use Fintech\Core\Facades\Core;
use Fintech\MetaData\Facades\MetaData;
use Illuminate\Console\Command;

class AgraniInstallCommand extends Command
Expand Down Expand Up @@ -255,12 +256,12 @@ public function handle(): int
public function addCountryCodeToCountries(): void
{
if (Core::packageExists('MetaData')) {
\Fintech\MetaData\Facades\MetaData::country()
MetaData::country()
->list(['paginate' => false])
->each(function ($country) {
$countryData = $country->country_data;
$countryData['vendor_code']['agrani_code'] = self::AGRANI_CODES[$country->iso3]['agrani_code'] ?? null;
\Fintech\MetaData\Facades\MetaData::country()->update($country->getKey(), ['country_data' => $countryData]);
MetaData::country()->update($country->getKey(), ['country_data' => $countryData]);
$this->info("Country ID: {$country->getKey()} successful.");
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/OrderQuotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Fintech\Remit\Contracts;

use MongoDB\Laravel\Eloquent\Model;

interface OrderQuotation
{
/**
* @param \Illuminate\Database\Eloquent\Model|\MongoDB\Laravel\Eloquent\Model $order
* @param \Illuminate\Database\Eloquent\Model|Model $order
*/
public function requestQuotation($order): mixed;
}
8 changes: 6 additions & 2 deletions src/Events/RemitTransferFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Fintech\Remit\Events;

use Fintech\Remit\Models\BankTransfer;
use Fintech\Remit\Models\CashPickup;
use Fintech\Remit\Models\WalletTransfer;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -16,7 +20,7 @@ class RemitTransferFailed
/**
* Create a new event instance.
*
* @param \Fintech\Remit\Models\BankTransfer|\Fintech\Remit\Models\CashPickup|\Fintech\Remit\Models\WalletTransfer
* @param BankTransfer|CashPickup|WalletTransfer
*/
public function __construct($transfer)
{
Expand All @@ -26,7 +30,7 @@ public function __construct($transfer)
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
* @return array<int, Channel>
*/
public function broadcastOn(): array
{
Expand Down
8 changes: 6 additions & 2 deletions src/Events/RemitTransferRejected.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Fintech\Remit\Events;

use Fintech\Remit\Models\BankTransfer;
use Fintech\Remit\Models\CashPickup;
use Fintech\Remit\Models\WalletTransfer;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -16,7 +20,7 @@ class RemitTransferRejected
/**
* Create a new event instance.
*
* @param \Fintech\Remit\Models\BankTransfer|\Fintech\Remit\Models\CashPickup|\Fintech\Remit\Models\WalletTransfer
* @param BankTransfer|CashPickup|WalletTransfer
*/
public function __construct($transfer)
{
Expand All @@ -26,7 +30,7 @@ public function __construct($transfer)
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
* @return array<int, Channel>
*/
public function broadcastOn(): array
{
Expand Down
Loading

0 comments on commit 4de552e

Please sign in to comment.