Skip to content

Commit

Permalink
Remove all model references in the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
phuclh committed Feb 5, 2021
1 parent 47d2942 commit a6ae44c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 32 deletions.
16 changes: 0 additions & 16 deletions config/payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,4 @@

return [

/**
* Model class references.
*/
'model_class' => [

'user' => \App\Models\User::class,

'order' => \App\Models\Order::class,

'customer' => \App\Models\Customer::class,

'invoice' => \App\Models\Invoice::class,

'refund' => \App\Models\Refund::class,
]

];
10 changes: 5 additions & 5 deletions database/factories/PaymentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function definition()
{
return [
'charge_id' => $this->faker->numberBetween(100000, 900000),
'order_id' => Support::randomOrCreate(config('payments.model_class.order')),
'customer_id' => Support::randomOrCreate(config('payments.model_class.customer')),
'invoice_id' => Support::randomOrCreate(config('payments.model_class.invoice')),
'order_id' => Support::randomOrCreate(config('tipoff.model_class.order')),
'customer_id' => Support::randomOrCreate(config('tipoff.model_class.customer')),
'invoice_id' => Support::randomOrCreate(config('tipoff.model_class.invoice')),
'amount' => $this->faker->numberBetween(100, 40000),
'method' => $this->faker->randomElement(['online', 'phone', 'in-person']),
'creator_id' => Support::randomOrCreate(config('payments.model_class.user')),
'updater_id' => Support::randomOrCreate(config('payments.model_class.user')),
'creator_id' => Support::randomOrCreate(config('tipoff.model_class.user')),
'updater_id' => Support::randomOrCreate(config('tipoff.model_class.user')),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class CreatePaymentsTable extends Migration
public function up()
{
Schema::create('payments', function (Blueprint $table) {
$userModel = config('payments.model_class.user');
$userModel = config('tipoff.model_class.user');
$userTable = (new $userModel)->getTable();

$customerModel = config('payments.model_class.customer');
$customerModel = config('tipoff.model_class.customer');
$customerTable = (new $customerModel)->getTable();

$orderModel = config('payments.model_class.order');
$orderModel = config('tipoff.model_class.order');
$orderTable = (new $orderModel)->getTable();

$invoiceModel = config('payments.model_class.invoice');
$invoiceModel = config('tipoff.model_class.invoice');
$invoiceTable = (new $invoiceModel)->getTable();

$table->id();
Expand Down
14 changes: 7 additions & 7 deletions src/Models/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,32 @@ protected static function boot()

public function order()
{
return $this->belongsTo(config('payments.model_class.order'));
return $this->belongsTo(config('tipoff.model_class.order'));
}

public function customer()
{
return $this->belongsTo(config('payments.model_class.customer'));
return $this->belongsTo(config('tipoff.model_class.customer'));
}

public function invoice()
{
return $this->belongsTo(config('payments.model_class.invoice'));
return $this->belongsTo(config('tipoff.model_class.invoice'));
}

public function creator()
{
return $this->belongsTo(config('payments.model_class.user'), 'creator_id');
return $this->belongsTo(config('tipoff.model_class.user'), 'creator_id');
}

public function updater()
{
return $this->belongsTo(config('payments.model_class.user'), 'updater_id');
return $this->belongsTo(config('tipoff.model_class.user'), 'updater_id');
}

public function refunds()
{
return $this->hasMany(config('payments.model_class.refund'));
return $this->hasMany(config('tipoff.model_class.refund'));
}

public function getAmountRefundableAttribute()
Expand Down Expand Up @@ -92,7 +92,7 @@ public function generateAmountRefunded()
*/
public function requestRefund($amount = null, $method = 'Stripe')
{
return config('payments.model_class.refund')::create([
return config('tipoff.model_class.refund')::create([
'amount' => $amount,
'method' => $method,
'payment_id' => $this->id,
Expand Down

0 comments on commit a6ae44c

Please sign in to comment.