where('service_id', $service_id)->delete(); } public static function deleteLabelAssignedAs($label_id): void { DB::table('labels_assigned')->where('label_id', $label_id)->delete(); } public static function insertLabelsAssigned(array $labels_array, string $service_id): void { for ($i = 1; $i <= 4; $i++) { if (!is_null($labels_array[($i - 1)])) { DB::table('labels_assigned')->insert(['label_id' => $labels_array[($i - 1)], 'service_id' => $service_id]); } } } public static function labelsCount(): int { return Cache::remember('labels_count', now()->addMonth(1), function () { return Labels::count(); }); } public function assigned(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(LabelsAssigned::class, 'label_id', 'id'); } }