Updated to use Eloquent rather than DB::table()

This commit is contained in:
cp6 2023-08-19 23:52:59 +10:00
parent ae9b23cba7
commit b512caecc7
4 changed files with 5 additions and 7 deletions

View File

@ -21,12 +21,12 @@ class Labels extends Model
public static function deleteLabelsAssignedTo($service_id): void
{
DB::table('labels_assigned')->where('service_id', $service_id)->delete();
LabelsAssigned::where('service_id', $service_id)->delete();
}
public static function deleteLabelAssignedAs($label_id): void
{
DB::table('labels_assigned')->where('label_id', $label_id)->delete();
LabelsAssigned::where('label_id', $label_id)->delete();
}
public static function insertLabelsAssigned(array $labels_array, string $service_id): void

View File

@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Locations extends Model
{
@ -20,7 +19,7 @@ class Locations extends Model
public static function allLocations(): array
{
return Cache::remember("locations", now()->addMonth(1), function () {
return DB::table('locations')->orderBy('name')->get()->toArray();
return self::orderBy('name')->get()->toArray();
});
}
}

View File

@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class OS extends Model
{
@ -20,7 +19,7 @@ class OS extends Model
public static function allOS(): array
{
return Cache::remember("operating_systems", now()->addMonth(1), function () {
return DB::table('os')->orderBy('name')->get()->toArray();
return self::orderBy('name')->get()->toArray();
});
}
}

View File

@ -20,7 +20,7 @@ class Providers extends Model
public static function allProviders(): array
{
return Cache::remember("providers", now()->addMonth(1), function () {
return DB::table('providers')->orderBy('name')->get()->toArray();
return self::orderBy('name')->get()->toArray();
});
}