Enable showing only client-related uploads

This commit is contained in:
Benjamin Beganović 2020-08-17 16:31:49 +02:00
parent d55cfc42cf
commit 0efaa767b9
3 changed files with 36 additions and 1 deletions

View File

@ -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);

View File

@ -3255,4 +3255,6 @@ return [
'document_details' => 'Details about the document',
'hash' => 'Hash',
'resources' => 'Resources',
];

View File

@ -9,6 +9,16 @@
<option>20</option>
</select>
</div>
<div class="flex items-center">
<div class="mr-3">
<input wire:click="statusChange('resources')" type="checkbox" class="form-checkbox cursor-pointer" id="resources-checkbox" checked>
<label for="resources-checkbox" class="text-sm cursor-pointer">{{ ctrans('texts.resources') }}</label>
</div>
<div class="mr-3">
<input wire:click="statusChange('client')" type="checkbox" class="form-checkbox cursor-pointer" id="client-checkbox">
<label for="client-checkbox" class="text-sm cursor-pointer">{{ ctrans('texts.client') }}</label>
</div>
</div>
</div>
<div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
<div class="align-middle inline-block min-w-full overflow-hidden rounded">