From d9fac4259ddc98a604baacafae834f5005ef6d68 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Mon, 27 Nov 2023 17:38:38 +0100 Subject: [PATCH] feat: implement summoner emote index --- .../Controllers/SummonerEmoteController.php | 11 ++-- app/View/Components/Emotes/List_all.php | 5 ++ resources/views/assets/index.blade.php | 2 +- .../components/emotes/list_all.blade.php | 41 +++++++++++++- .../components/emotes/searchbar.blade.php | 27 ++++++++++ resources/views/emotes/index.blade.php | 53 +++++++++++++++++++ 6 files changed, 132 insertions(+), 7 deletions(-) create mode 100644 resources/views/components/emotes/searchbar.blade.php diff --git a/app/Http/Controllers/SummonerEmoteController.php b/app/Http/Controllers/SummonerEmoteController.php index a44fb05..a59ac0e 100644 --- a/app/Http/Controllers/SummonerEmoteController.php +++ b/app/Http/Controllers/SummonerEmoteController.php @@ -4,14 +4,19 @@ namespace App\Http\Controllers; use App\Models\SummonerEmote; use Illuminate\Http\Request; +use Spatie\QueryBuilder\QueryBuilder; class SummonerEmoteController extends Controller { public function index() { - $this->authorize('viewAny', SummonerEmote::class); + $emotes = QueryBuilder::for(SummonerEmote::class) + ->allowedFilters('title') + ->defaultSort('-emote_id') + ->paginate(72) + ->appends(request()->query()); - return SummonerEmote::all(); + return view('emotes.index', compact('emotes')); } public function store(Request $request) @@ -29,8 +34,6 @@ class SummonerEmoteController extends Controller public function show(SummonerEmote $summonerEmote) { - $this->authorize('view', $summonerEmote); - return $summonerEmote; } diff --git a/app/View/Components/Emotes/List_all.php b/app/View/Components/Emotes/List_all.php index f1d7c45..21b8c6f 100644 --- a/app/View/Components/Emotes/List_all.php +++ b/app/View/Components/Emotes/List_all.php @@ -2,11 +2,16 @@ namespace App\View\Components\Emotes; +use App\Models\SummonerEmote; use Illuminate\Contracts\View\View; use Illuminate\View\Component; class List_all extends Component { + public function __construct(public SummonerEmote $emotes) + { + } + public function render(): View { return view('components.emotes.list_all'); diff --git a/resources/views/assets/index.blade.php b/resources/views/assets/index.blade.php index 330fed8..51ba521 100644 --- a/resources/views/assets/index.blade.php +++ b/resources/views/assets/index.blade.php @@ -69,7 +69,7 @@
Icons - Emotes + Emotes
diff --git a/resources/views/components/emotes/list_all.blade.php b/resources/views/components/emotes/list_all.blade.php index b80e6e0..4c0ac40 100644 --- a/resources/views/components/emotes/list_all.blade.php +++ b/resources/views/components/emotes/list_all.blade.php @@ -1,3 +1,40 @@ -
+ -
+
+

+ Summoner Emotes

+ + + +
+
+ + @foreach($emotes as $key => $emote) +
+
+ {{ $emote->title }} Emote +
+ +
+
+

+ {{ $emote->title }} +

+
+
+
+ @endforeach +
+
+ {{ $emotes->links() }} +
diff --git a/resources/views/components/emotes/searchbar.blade.php b/resources/views/components/emotes/searchbar.blade.php new file mode 100644 index 0000000..897df9f --- /dev/null +++ b/resources/views/components/emotes/searchbar.blade.php @@ -0,0 +1,27 @@ +
+
+
+ + @if(request('filter.title')) + + @endif +
+ +
+
+ diff --git a/resources/views/emotes/index.blade.php b/resources/views/emotes/index.blade.php index e69de29..7218fa6 100644 --- a/resources/views/emotes/index.blade.php +++ b/resources/views/emotes/index.blade.php @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + Heimerdinger.LoL • Emotes + + + + + + + + + + + + + + + + + + + + + + @vite(['resources/css/app.css', 'resources/js/app.js']) + + + + + + + + +