From 4d82f5cffa3b5118449be3684398a891b2d38174 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 21 Feb 2022 22:57:06 +0800 Subject: [PATCH] fix Setting::get() --- app/Http/Controllers/TorrentController.php | 3 ++- app/Models/Setting.php | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 3191131c..5e62b459 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Resources\TorrentResource; +use App\Models\Setting; use App\Models\Torrent; use App\Repositories\TorrentRepository; use Illuminate\Http\Request; @@ -21,7 +22,7 @@ class TorrentController extends Controller { $params = $request->all(); $params['visible'] = Torrent::VISIBLE_YES; - $params['category_mode'] = get_setting('main.browsecat'); + $params['category_mode'] = Setting::get('main.browsecat'); $result = $this->repository->getList($params); $resource = TorrentResource::collection($result); $resource->additional([ diff --git a/app/Models/Setting.php b/app/Models/Setting.php index a0deb30e..7230f10e 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -15,9 +15,11 @@ class Setting extends NexusModel $rows = self::query()->get(['name', 'value']); foreach ($rows as $row) { $value = $row->value; - $arr = json_decode($value, true); - if (is_array($arr)) { - $value = $arr; + if (!is_null($value)) { + $arr = json_decode($value, true); + if (is_array($arr)) { + $value = $arr; + } } Arr::set($settings, $row->name, $value); }