Skip to content

Commit

Permalink
Update payavel/orchestration to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Jun 27, 2024
1 parent 3f8f726 commit aec82bd
Show file tree
Hide file tree
Showing 28 changed files with 94 additions and 93 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "vendor/bin/phpunit"
},
"require": {
"payavel/orchestration": "^2.0"
"payavel/orchestration": "dev-master"
},
"require-dev": {
"orchestra/testbench": "^8.0|^9.0"
Expand Down
4 changes: 2 additions & 2 deletions database/factories/TransactionEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Payavel\Checkout\Models\Payment;
use Payavel\Checkout\Models\Refund;
use Payavel\Checkout\Models\TransactionEvent;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;

class TransactionEventFactory extends Factory
{
Expand Down Expand Up @@ -38,7 +38,7 @@ public function definition()
*/
public function configure()
{
$this->model = ServiceConfig::get('checkout', 'models.' . $this->model, $this->model);
$this->model = ServiceConfig::find('checkout')->get('models.' . $this->model, $this->model);

return $this->afterMaking(function (TransactionEvent $transactionEvent) {
if (is_null($transactionEvent->payment_id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;

return new class () extends Migration {
/**
Expand All @@ -13,7 +13,7 @@
*/
public function up()
{
$usingDatabaseDriver = ServiceConfig::get('checkout', 'defaults.driver') === 'database';
$usingDatabaseDriver = ServiceConfig::find('checkout')->get('defaults.driver') === 'database';

Schema::create('payment_types', function (Blueprint $table) {
$table->string('id')->primary();
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class Dispute extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Payment::class, Payment::class));
}

/**
Expand All @@ -62,6 +62,6 @@ public function payment()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(ServiceConfig::find('checkout')->get('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}
}
14 changes: 7 additions & 7 deletions src/Models/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Payavel\Orchestration\Contracts\Orchestrable;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\OrchestratesService;
use Payavel\Orchestration\Traits\HasFactory;

Expand Down Expand Up @@ -64,7 +64,7 @@ protected static function getFactoryNamespace()
*/
public function provider()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Provider::class, Provider::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Provider::class, Provider::class));
}

/**
Expand All @@ -74,7 +74,7 @@ public function provider()
*/
public function account()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Account::class, Account::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Account::class, Account::class));
}

/**
Expand All @@ -84,7 +84,7 @@ public function account()
*/
public function rail()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentRail::class, PaymentRail::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . PaymentRail::class, PaymentRail::class));
}

/**
Expand All @@ -94,7 +94,7 @@ public function rail()
*/
public function instrument()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . PaymentInstrument::class, PaymentInstrument::class));
}

/**
Expand All @@ -104,7 +104,7 @@ public function instrument()
*/
public function events()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class));
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . TransactionEvent::class, TransactionEvent::class));
}

/**
Expand All @@ -114,7 +114,7 @@ public function events()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(ServiceConfig::find('checkout')->get('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/PaymentInstrument.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentInstrument extends Model
Expand Down Expand Up @@ -53,7 +53,7 @@ protected static function getFactoryNamespace()
*/
public function wallet()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Wallet::class, Wallet::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Wallet::class, Wallet::class));
}

/**
Expand All @@ -63,7 +63,7 @@ public function wallet()
*/
public function type()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -73,7 +73,7 @@ public function type()
*/
public function payments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class), 'instrument_id');
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . Payment::class, Payment::class), 'instrument_id');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/PaymentRail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentRail extends Model
Expand Down Expand Up @@ -54,7 +54,7 @@ protected static function getFactoryNamespace()
*/
public function parentType()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -64,7 +64,7 @@ public function parentType()
*/
public function type()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -74,6 +74,6 @@ public function type()
*/
public function payments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class), 'rail_id');
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . Payment::class, Payment::class), 'rail_id');
}
}
6 changes: 3 additions & 3 deletions src/Models/PaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentType extends Model
Expand Down Expand Up @@ -41,7 +41,7 @@ protected static function getFactoryNamespace()
*/
public function rails()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentRail::class, PaymentRail::class), 'parent_type_id');
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . PaymentRail::class, PaymentRail::class), 'parent_type_id');
}

/**
Expand All @@ -51,6 +51,6 @@ public function rails()
*/
public function instruments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class), 'type_id');
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . PaymentInstrument::class, PaymentInstrument::class), 'type_id');
}
}
6 changes: 3 additions & 3 deletions src/Models/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class Refund extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Payment::class, Payment::class));
}

/**
Expand All @@ -62,6 +62,6 @@ public function payment()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(ServiceConfig::find('checkout')->get('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}
}
4 changes: 2 additions & 2 deletions src/Models/TransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class TransactionEvent extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Payment::class, Payment::class));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Payavel\Orchestration\Traits\OrchestratesService;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class Wallet extends Model implements Orchestrable
Expand Down Expand Up @@ -63,7 +63,7 @@ public function billable()
*/
public function provider()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Provider::class, Provider::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Provider::class, Provider::class));
}

/**
Expand All @@ -73,7 +73,7 @@ public function provider()
*/
public function account()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Account::class, Account::class));
return $this->belongsTo(ServiceConfig::find('checkout')->get('models.' . Account::class, Account::class));
}

/**
Expand All @@ -83,7 +83,7 @@ public function account()
*/
public function paymentInstruments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class));
return $this->hasMany(ServiceConfig::find('checkout')->get('models.' . PaymentInstrument::class, PaymentInstrument::class));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Traits;

use Payavel\Checkout\Models\Wallet;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Fluent\ServiceConfig;

trait Billable
{
Expand All @@ -14,6 +14,6 @@ trait Billable
*/
public function wallets()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . Wallet::class, Wallet::class), 'billable');
return $this->morphMany(ServiceConfig::find('checkout')->get('models.' . Wallet::class, Wallet::class), 'billable');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ class ConfigCheckoutInstallCommandTest extends TestCheckoutInstallCommand

protected function makeSureProviderExists(Providable $provider)
{
$config = require(config_path(Str::slug($this->checkoutService->getId()) . '.php'));
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));

$this->assertIsArray($config['providers']);
$this->assertIsArray($config['providers'][$provider->getId()]);
$this->assertEquals(
'App\\Services\\' . Str::studly($this->checkoutService->getId()) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->getId()) . 'Request',
'App\\Services\\' . Str::studly($this->checkoutService->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->id) . 'Request',
$config['providers'][$provider->getId()]['gateway']
);
}

protected function makeSureAccountExists(Accountable $account)
{
$config = require(config_path(Str::slug($this->checkoutService->getId()) . '.php'));
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));

$this->assertIsArray($config['accounts']);
$this->assertIsArray($config['accounts'][$account->getId()]);
Expand All @@ -37,7 +37,7 @@ protected function makeSureAccountExists(Accountable $account)

protected function makeSureProviderIsLinkedToAccount(Providable $provider, Accountable $account)
{
$config = require(config_path(Str::slug($this->checkoutService->getId()) . '.php'));
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));

$this->assertIsArray($config['accounts'][$account->getId()]['providers'][$provider->getId()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function makeSureProviderExists(Providable $provider)

$this->assertNotNull($provider);
$this->assertEquals(
'App\\Services\\' . Str::studly($this->checkoutService->getId()) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->getId()) . 'Request',
'App\\Services\\' . Str::studly($this->checkoutService->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->id) . 'Request',
$provider->gateway
);
}
Expand Down Expand Up @@ -62,8 +62,8 @@ private function migrate()
return;
}

Account::where('service_id', $this->checkoutService->getId())->delete();
Provider::where('service_id', $this->checkoutService->getId())->delete();
Account::where('service_id', $this->checkoutService->id)->delete();
Provider::where('service_id', $this->checkoutService->id)->delete();

$this->artisan('migrate');

Expand Down
Loading

0 comments on commit aec82bd

Please sign in to comment.