diff --git a/app/Http/Livewire/DownloadsTable.php b/app/Http/Livewire/DownloadsTable.php index d8225b647990..2e3fddff70e5 100644 --- a/app/Http/Livewire/DownloadsTable.php +++ b/app/Http/Livewire/DownloadsTable.php @@ -13,9 +13,32 @@ class DownloadsTable extends Component public $per_page = 10; + public $status = [ + 'resources', + ]; + + public function statusChange($status) + { + if (in_array($status, $this->status)) { + return $this->status = array_diff($this->status, [$status]); + } + + array_push($this->status, $status); + } + public function render() { - $query = Document::query() + $query = Document::query(); + + if (in_array('resources', $this->status) && !in_array('client', $this->status)) { + $query = $query->where('documentable_type', '!=', 'App\Models\Client'); + } + + if (in_array('client', $this->status) && !in_array('resources', $this->status)) { + $query = $query->where('documentable_type', 'App\Models\Client'); + } + + $query = $query ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->paginate($this->per_page); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index d0ef20158f8d..3c174bf6f1d6 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3255,4 +3255,6 @@ return [ 'document_details' => 'Details about the document', 'hash' => 'Hash', + + 'resources' => 'Resources', ]; diff --git a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php index 0413d185eb7f..231c60b2703b 100644 --- a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php @@ -9,6 +9,16 @@ +
+
+ + +
+
+ + +
+