mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 06:24:03 +00:00
Merge branch 'dillon/63.3-sorry-voucher-debug' into development
This commit is contained in:
@@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
interface KeyValueInterface
|
||||
{
|
||||
|
||||
public function attributes(): morphMany;
|
||||
public function attributesKVP(): morphMany;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributes(), $model);
|
||||
return $this->handler($kv->attributesKVP(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class CreateVoucherLogic extends AbstractControllerLogic
|
||||
$key,
|
||||
$total
|
||||
);
|
||||
$metadata = $voucherCampaign->attributes()->where('key', $key)->first();
|
||||
$metadata = $voucherCampaign->attributesKVP()->where('key', $key)->first();
|
||||
if($metadata){
|
||||
$this->updatesKeyValuePair->execute($metadata, $keyValuePairObject);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Vouchers\Standards\Rules;
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Vouchers\Standards\Validators\VoucherValidation;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\CreateVoucherObject;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Classes\ValueObjects\Constants\Vouchers;
|
||||
|
||||
@@ -34,7 +35,8 @@ class CanCreateVoucher extends AbstractRule
|
||||
case Vouchers::SORRY_50:
|
||||
case Vouchers::SORRY_100:
|
||||
case Vouchers::SORRY_200:
|
||||
$isAuthorized = Auth::user()->can('add voucher');
|
||||
// $isAuthorized = Auth::user()->can('add voucher');
|
||||
$isAuthorized = in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES);
|
||||
break;
|
||||
default:
|
||||
$isAuthorized = true;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Vouchers\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class CanListVoucherCampaigns extends AbstractRule
|
||||
{
|
||||
@@ -14,63 +14,8 @@ class CanListVoucherCampaigns extends AbstractRule
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
Log::info('view document: ' . Auth::user()->can('view document'));
|
||||
Log::info('add document: ' . Auth::user()->can('add document'));
|
||||
Log::info('edit document: ' . Auth::user()->can('edit document'));
|
||||
Log::info('delete document: ' . Auth::user()->can('delete document'));
|
||||
|
||||
Log::info('view standard_segment: ' . Auth::user()->can('view standard_segment'));
|
||||
Log::info('add standard_segment: ' . Auth::user()->can('add standard_segment'));
|
||||
Log::info('edit standard_segment: ' . Auth::user()->can('edit standard_segment'));
|
||||
Log::info('delete standard_segment: ' . Auth::user()->can('delete standard_segment'));
|
||||
|
||||
Log::info('view standard_segment_constant: ' . Auth::user()->can('view standard_segment_constant'));
|
||||
Log::info('add standard_segment_constant: ' . Auth::user()->can('add standard_segment_constant'));
|
||||
Log::info('edit standard_segment_constant: ' . Auth::user()->can('edit standard_segment_constant'));
|
||||
Log::info('delete standard_segment_constant: ' . Auth::user()->can('delete standard_segment_constant'));
|
||||
|
||||
Log::info('view segment: ' . Auth::user()->can('view segment'));
|
||||
Log::info('add segment: ' . Auth::user()->can('add segment'));
|
||||
Log::info('edit segment: ' . Auth::user()->can('edit segment'));
|
||||
Log::info('delete segment: ' . Auth::user()->can('delete segment'));
|
||||
|
||||
Log::info('view segment_constant: ' . Auth::user()->can('view segment_constant'));
|
||||
Log::info('add segment_constant: ' . Auth::user()->can('add segment_constant'));
|
||||
Log::info('edit segment_constant: ' . Auth::user()->can('edit segment_constant'));
|
||||
Log::info('delete segment_constant: ' . Auth::user()->can('delete segment_constant'));
|
||||
|
||||
Log::info('view company_bank: ' . Auth::user()->can('view company_bank'));
|
||||
Log::info('add company_bank: ' . Auth::user()->can('add company_bank'));
|
||||
Log::info('edit company_bank: ' . Auth::user()->can('edit company_bank'));
|
||||
Log::info('delete company_bank: ' . Auth::user()->can('delete company_bank'));
|
||||
|
||||
Log::info('view currency: ' . Auth::user()->can('view currency'));
|
||||
Log::info('add currency: ' . Auth::user()->can('add currency'));
|
||||
Log::info('edit currency: ' . Auth::user()->can('edit currency'));
|
||||
Log::info('delete currency: ' . Auth::user()->can('delete currency'));
|
||||
|
||||
Log::info('view currency_rate: ' . Auth::user()->can('view currency_rate'));
|
||||
Log::info('add currency_rate: ' . Auth::user()->can('add currency_rate'));
|
||||
Log::info('edit currency_rate: ' . Auth::user()->can('edit currency_rate'));
|
||||
Log::info('delete currency_rate: ' . Auth::user()->can('delete currency_rate'));
|
||||
|
||||
Log::info('view booking: ' . Auth::user()->can('view booking'));
|
||||
Log::info('add booking: ' . Auth::user()->can('add booking'));
|
||||
Log::info('edit booking: ' . Auth::user()->can('edit booking'));
|
||||
Log::info('delete booking: ' . Auth::user()->can('delete booking'));
|
||||
|
||||
Log::info('add milestone: ' . Auth::user()->can('add milestone'));
|
||||
Log::info('add reward: ' . Auth::user()->can('add reward'));
|
||||
Log::info('edit milestone: ' . Auth::user()->can('edit milestone'));
|
||||
Log::info('delete milestone: ' . Auth::user()->can('delete milestone'));
|
||||
Log::info('delete reward: ' . Auth::user()->can('delete reward'));
|
||||
|
||||
Log::info('add voucher: ' . Auth::user()->can('add voucher'));
|
||||
Log::info('list voucher campaigns: ' . Auth::user()->can('list voucher campaigns'));
|
||||
Log::info('update bank_metadata: ' . Auth::user()->can('update bank_metadata'));
|
||||
|
||||
|
||||
if (!Auth::user()->can('list voucher campaigns')) {
|
||||
// if (!Auth::user()->can('list voucher campaigns')) {
|
||||
if (!in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserRewardResource extends JsonResource
|
||||
{
|
||||
$emailReminder = null;
|
||||
if ($request->has('isAdmin')) {
|
||||
$keyValuePairs = $this->user->attributes()->get();
|
||||
$keyValuePairs = $this->user->attributesKVP()->get();
|
||||
$emailReminder = KeyValueBasicResource::collection($keyValuePairs);
|
||||
$this->voucher->email = $emailReminder;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class VoucherCampaignResource extends JsonResource
|
||||
{
|
||||
$metadata = null;
|
||||
if ($request->has('include_metadata')) {
|
||||
$metadata = KeyValueBasicResource::collection($this->attributes);
|
||||
$metadata = KeyValueBasicResource::collection($this->attributesKVP()->latest()->get());
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ class User extends AbstractModel implements
|
||||
|
||||
public function hasAttribute(string $key, $value = null): bool
|
||||
{
|
||||
$query = $this->attributes()->where('key', $key);
|
||||
$query = $this->attributesKVP()->where('key', $key);
|
||||
|
||||
if ($value !== null) {
|
||||
$query->where('value', $value);
|
||||
@@ -116,7 +116,7 @@ class User extends AbstractModel implements
|
||||
}
|
||||
|
||||
|
||||
public function attributes(): MorphMany
|
||||
public function attributesKVP(): MorphMany
|
||||
{
|
||||
return $this->morphMany(KeyValuePair::class, 'owner');
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class VoucherCampaign extends AbstractModel implements KeyValueInterface
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attributes(): MorphMany
|
||||
public function attributesKVP(): MorphMany
|
||||
{
|
||||
return $this->morphMany(KeyValuePair::class, 'owner');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user