mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Vourcherify
This commit is contained in:
@@ -112,6 +112,14 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
return $this->HasOne(GroupTransaction::class, 'transaction_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne
|
||||
*/
|
||||
public function voucherRedemption(): HasOne
|
||||
{
|
||||
return $this->HasOne(VoucherRedemption::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
public function convert_original_amount()
|
||||
{
|
||||
if($this->booking()->first()->fix_currency_id !== 1) {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
@@ -65,4 +66,12 @@ class User extends AbstractModel implements
|
||||
{
|
||||
return $this->belongsToMany(Company::class, (new Employee())->getTable(), 'user_id', 'company_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function redemptions(): HasMany
|
||||
{
|
||||
return $this->HasMany(VoucherRedemption::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
|
||||
class Voucher extends AbstractModel
|
||||
{
|
||||
protected $table = 'vouchers';
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function redemptions(): HasMany
|
||||
{
|
||||
return $this->HasMany(VoucherRedemption::class, 'voucher_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
|
||||
class VoucherRedemption extends AbstractModel
|
||||
{
|
||||
protected $table = 'voucher_redemptions';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function voucher(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Voucher::class, 'voucher_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transaction(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Transaction::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user