From 685a427c13fef86f8a6923ffe54f15f860efdb1b Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 28 May 2021 02:25:08 +0800 Subject: [PATCH] render searchbox relate icon css --- app/Console/Commands/Test.php | 11 +++++++---- app/Models/Category.php | 5 +++++ app/Models/Icon.php | 11 +++++++++++ app/Models/SearchBox.php | 3 --- app/Repositories/SearchBoxRepository.php | 8 ++++++++ include/functions.php | 10 +++++++--- 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 app/Models/Icon.php diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 0b48eb1a..fbf39f4e 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use App\Models\Exam; use App\Models\ExamProgress; use App\Models\ExamUser; +use App\Models\SearchBox; use App\Models\User; use App\Repositories\ExamRepository; use App\Repositories\SearchBoxRepository; @@ -66,10 +67,12 @@ class Test extends Command // $rep = new SearchBoxRepository(); // $r = $rep->initSearchBoxField(4); - $imdb = new \Nexus\Imdb\Imdb(); - $imdb_id = 5768840; - $r = $imdb->getMovie($imdb_id)->photo(true); - dd($r); +// $imdb = new \Nexus\Imdb\Imdb(); +// $imdb_id = 5768840; +// $r = $imdb->getMovie($imdb_id)->photo(true); + + $searchbox = (new SearchBoxRepository())->listIcon(4); + dd($searchbox); } } diff --git a/app/Models/Category.php b/app/Models/Category.php index 6801cfe3..0fca4a1e 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -8,4 +8,9 @@ class Category extends NexusModel protected $table = 'categories'; protected $fillable = ['mode', 'name', 'class_name', 'image', 'sort_index', 'icon_id']; + + public function icon(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Icon::class, 'icon_id'); + } } diff --git a/app/Models/Icon.php b/app/Models/Icon.php new file mode 100644 index 00000000..ed9aba6c --- /dev/null +++ b/app/Models/Icon.php @@ -0,0 +1,11 @@ +hasMany(SearchBoxField::class, 'searchbox_id'); } - - - } diff --git a/app/Repositories/SearchBoxRepository.php b/app/Repositories/SearchBoxRepository.php index fb99bcbf..921e5c16 100644 --- a/app/Repositories/SearchBoxRepository.php +++ b/app/Repositories/SearchBoxRepository.php @@ -2,6 +2,7 @@ namespace App\Repositories; +use App\Models\Icon; use App\Models\NexusModel; use App\Models\SearchBox; use App\Models\SearchBoxField; @@ -80,5 +81,12 @@ class SearchBoxRepository extends BaseRepository } } + public function listIcon($id) + { + $searchBox = SearchBox::query()->findOrFail($id); + $iconIdArr = $searchBox->categories->pluck('icon_id')->unique(); + return Icon::query()->find($iconIdArr); + } + } diff --git a/include/functions.php b/include/functions.php index 80589964..cf1f40cc 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2254,6 +2254,7 @@ function stdhead($title = "", $msgalert = true, $script = "", $place = "") global $tstart; global $Cache; global $Advertisement; + global $browsecatmode; $Cache->setLanguage($CURLANGDIR); @@ -2322,10 +2323,13 @@ $cssupdatedate=($cssupdatedate ? "?".htmlspecialchars($cssupdatedate) : ""); listIcon($browsecatmode); + foreach ($icons as $icon) { ?> - +