From bb07f86deb14843cefc2b5669c2df27fdc739a31 Mon Sep 17 00:00:00 2001 From: cp6 Date: Wed, 20 Jul 2022 14:36:19 +1000 Subject: [PATCH] Updated Labels class Removed unused function Added assigned() hasMany --- app/Models/Labels.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Models/Labels.php b/app/Models/Labels.php index 50f1840..02fd417 100644 --- a/app/Models/Labels.php +++ b/app/Models/Labels.php @@ -43,14 +43,9 @@ class Labels extends Model }); } - public static function labelsForService(string $service_id) + public function assigned() { - return Cache::remember("labels_for_service.$service_id", now()->addMinute(5), function () use ($service_id) { - return DB::table('labels_assigned as l') - ->join('labels', 'l.label_id', '=', 'labels.id') - ->where('l.service_id', '=', $service_id) - ->get(['labels.id', 'labels.label']); - }); + return $this->hasMany(LabelsAssigned::class, 'label_id', 'id'); } }