mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 15:34:02 +00:00
Merge branch 'affiliate-program' of https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0 into vapor/development
# Conflicts: # routes/api.php
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\CreateAffiliateLogic;
|
||||
use App\Http\Requests\CreateAffiliateRequest;
|
||||
use App\Models\Affiliate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class CreateAffiliateController
|
||||
{
|
||||
/**
|
||||
* @param CreateAffiliateRequest $request
|
||||
* @param CreateAffiliateLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function create(CreateAffiliateRequest $request, CreateAffiliateLogic $logic): JsonResponse {
|
||||
$this->authorize('create', Affiliate::class);
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize a given action for the current user.
|
||||
*
|
||||
* @param mixed $ability
|
||||
* @param mixed|array $arguments
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorize($ability, $arguments = [])
|
||||
{
|
||||
return app(\Illuminate\Contracts\Auth\Access\Gate::class)->authorize($ability, $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\DeleteAffiliateLogic;
|
||||
use App\Models\Affiliate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class DeleteAffiliateController
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
* @param DeleteAffiliateLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function delete(int $id, DeleteAffiliateLogic $logic): JsonResponse {
|
||||
$affiliate = Affiliate::findOrFail($id);
|
||||
$this->authorize('delete', $affiliate);
|
||||
return $logic->execute($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize a given action for the current user.
|
||||
*
|
||||
* @param mixed $ability
|
||||
* @param mixed|array $arguments
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorize($ability, $arguments = [])
|
||||
{
|
||||
return app(\Illuminate\Contracts\Auth\Access\Gate::class)->authorize($ability, $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\GetAffiliateSettingsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class GetAffiliateSettingsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param GetAffiliateSettingsLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function get(Request $request, GetAffiliateSettingsLogic $logic): JsonResponse {
|
||||
Gate::authorize('manageSettings', \App\Models\Affiliate::class);
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\ListAffiliatesLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class ListAffiliatesController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListAffiliatesLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function list(Request $request, ListAffiliatesLogic $logic): JsonResponse {
|
||||
Gate::authorize('viewAny', \App\Models\Affiliate::class);
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\UpdateAffiliateLogic;
|
||||
use App\Http\Requests\UpdateAffiliateRequest;
|
||||
use App\Models\Affiliate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UpdateAffiliateController
|
||||
{
|
||||
/**
|
||||
* @param UpdateAffiliateRequest $request
|
||||
* @param int $id
|
||||
* @param UpdateAffiliateLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function update(UpdateAffiliateRequest $request, int $id, UpdateAffiliateLogic $logic): JsonResponse {
|
||||
$affiliate = Affiliate::findOrFail($id);
|
||||
$this->authorize('update', $affiliate);
|
||||
return $logic->execute($request, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize a given action for the current user.
|
||||
*
|
||||
* @param mixed $ability
|
||||
* @param mixed|array $arguments
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorize($ability, $arguments = [])
|
||||
{
|
||||
return app(\Illuminate\Contracts\Auth\Access\Gate::class)->authorize($ability, $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Affiliate;
|
||||
|
||||
use App\Classes\Modules\Affiliate\ControllersLogic\UpdateAffiliateSettingsLogic;
|
||||
use App\Http\Requests\UpdateAffiliateSettingsRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UpdateAffiliateSettingsController
|
||||
{
|
||||
/**
|
||||
* @param UpdateAffiliateSettingsRequest $request
|
||||
* @param UpdateAffiliateSettingsLogic $logic
|
||||
* @return JsonResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function update(UpdateAffiliateSettingsRequest $request, UpdateAffiliateSettingsLogic $logic): JsonResponse {
|
||||
// Check if user has permission to manage affiliate settings
|
||||
Gate::authorize('manageSettings', \App\Models\Affiliate::class);
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user