Skip to content

Commit

Permalink
Updated Settings.php
Browse files Browse the repository at this point in the history
getSettings() now uses Eloquent rather than DB
Gave getSettings() return type of Settings
  • Loading branch information
cp6 committed Mar 31, 2023
1 parent f488e10 commit a683f0e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/Models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;

class Settings extends Model
Expand All @@ -16,11 +15,10 @@ class Settings extends Model

protected $fillable = ['id', 'show_versions_footer', 'show_servers_public', 'show_server_value_ip', 'show_server_value_hostname', 'show_server_value_provider', 'show_server_value_location', 'show_server_value_price', 'show_server_value_yabs', 'save_yabs_as_txt', 'default_currency', 'default_server_os', 'due_soon_amount', 'recently_added_amount', 'dark_mode', 'dashboard_currency', 'sort_on', 'favicon'];

public static function getSettings()
public static function getSettings(): Settings
{
return Cache::remember('settings', now()->addWeek(1), function () {
return DB::table('settings')->where('id', '=', 1)
->first();
return self::where('id', 1)->first();
});
}

Expand Down Expand Up @@ -72,5 +70,4 @@ public static function orderByProcess(int $value): array
return ['created_at', 'desc'];
}


}

0 comments on commit a683f0e

Please sign in to comment.