From 651b5b5412dd69c279473b31e7f249ae0151f3db Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Tue, 26 Apr 2022 20:35:32 -0700 Subject: [PATCH] searchin --- app/Http/Livewire/Admin/ListFanlistings.php | 16 +++++++++++----- app/helpers.php | 12 +++++++----- public/css/admin/style.css | 13 ++++++++++--- resources/sass/admin/_base.scss | 8 ++++++++ .../livewire/admin/list-fanlistings.blade.php | 2 ++ 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/Http/Livewire/Admin/ListFanlistings.php b/app/Http/Livewire/Admin/ListFanlistings.php index a3f71a6..7680de2 100644 --- a/app/Http/Livewire/Admin/ListFanlistings.php +++ b/app/Http/Livewire/Admin/ListFanlistings.php @@ -11,14 +11,20 @@ class ListFanlistings extends Component use WithPagination; public string $class; + public string $searchTerm = ''; + + public function mount($class) + { + $this->class = strtolower($class); + } public function render() { - if ($this->class == 'joined') { - $fanlistings = auth_collective()->joined()->paginate(8); - } elseif ($this->class == 'owned') { - // TODO: add owned class - } + $search = '%' . $this->searchTerm . '%'; + $fanlistings = auth_collective()->{$this->class}() + ->where('subject', 'like', $search) + ->paginate(PER_PAGE); + $fanlistings->load(['categories']); return view('livewire.admin.list-fanlistings', [ 'fanlistings' => $fanlistings, diff --git a/app/helpers.php b/app/helpers.php index 9bf7d20..4920426 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,5 +1,7 @@ user(); - } -} \ No newline at end of file + function auth_collective() : Collective + { + return auth()->user(); + } +} diff --git a/public/css/admin/style.css b/public/css/admin/style.css index 0ee1c5b..3f2c92b 100644 --- a/public/css/admin/style.css +++ b/public/css/admin/style.css @@ -115,7 +115,7 @@ .form__label:first-child, .form__btns:first-child, .form__checkbox:first-child, margin-top: 0; } -.form__input, .form__select { +.form__input, .form__input--search, .form__select { border: 1px solid #7874ff; background-color: #e4e3ff; border-color: #7874ff; @@ -123,13 +123,13 @@ .form__input, .form__select { color: #7874ff; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } -.form__input:hover, .form__select:hover { +.form__input:hover, .form__input--search:hover, .form__select:hover { border-color: #de7cff; background-color: #f8e5ff; color: #de7cff; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } -.form__input:focus, .form__select:focus { +.form__input:focus, .form__input--search:focus, .form__select:focus { border-color: #de7cff; background-color: #f8e5ff; color: #de7cff; @@ -153,6 +153,13 @@ .form__input--file:focus { color: #de7cff; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } +.form__input--search { + width: 60%; + display: block; + margin: 0 auto; + margin-bottom: 20px; +} + .form__input--checkbox { -webkit-appearance: none; -moz-appearance: none; diff --git a/resources/sass/admin/_base.scss b/resources/sass/admin/_base.scss index 27e8ac2..c579d2a 100644 --- a/resources/sass/admin/_base.scss +++ b/resources/sass/admin/_base.scss @@ -75,6 +75,14 @@ h1 { } } +.form__input--search { + @extend .form__input; + width: 60%; + display: block; + margin: 0 auto; + margin-bottom: 20px; +} + .form__checkbox { @extend .form__label; } diff --git a/resources/views/livewire/admin/list-fanlistings.blade.php b/resources/views/livewire/admin/list-fanlistings.blade.php index bc3c918..fd717fa 100644 --- a/resources/views/livewire/admin/list-fanlistings.blade.php +++ b/resources/views/livewire/admin/list-fanlistings.blade.php @@ -1,4 +1,6 @@
+