From 20f06e4fe6c3fe5ba26a7c86c48f2f6cc94b0f37 Mon Sep 17 00:00:00 2001 From: Paul Grimes Date: Tue, 3 Dec 2024 11:39:42 +1300 Subject: [PATCH] Added createdByUser relation on voucher set --- .../Api/V1/Admin/ApiAdminVoucherSetsController.php | 2 +- app/Models/VoucherSet.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/V1/Admin/ApiAdminVoucherSetsController.php b/app/Http/Controllers/Api/V1/Admin/ApiAdminVoucherSetsController.php index 2bdbed08..f9e30b13 100644 --- a/app/Http/Controllers/Api/V1/Admin/ApiAdminVoucherSetsController.php +++ b/app/Http/Controllers/Api/V1/Admin/ApiAdminVoucherSetsController.php @@ -35,6 +35,7 @@ class ApiAdminVoucherSetsController extends Controller * Set the related data the GET request is allowed to ask for */ public array $availableRelations = [ + 'createdByUser', 'createdByTeam', 'allocatedToServiceTeam', 'currencyCountry', @@ -121,7 +122,6 @@ class ApiAdminVoucherSetsController extends Controller )] public function index(): JsonResponse { - $this->query = VoucherSet::with($this->associatedData); $this->query = $this->updateReadQueryBasedOnUrl(); $this->data = $this->query->paginate($this->limit); diff --git a/app/Models/VoucherSet.php b/app/Models/VoucherSet.php index 03549a09..a03c831a 100644 --- a/app/Models/VoucherSet.php +++ b/app/Models/VoucherSet.php @@ -35,6 +35,12 @@ public function createdByTeam(): BelongsTo return $this->belongsTo(Team::class, 'created_by_team_id', 'id'); } + public function createdByUser(): BelongsTo + { + return $this->belongsTo(User::class, 'created_by_user_id', 'id'); + } + + /** * @return BelongsTo */