This commit is contained in:
Benjamin Beganović 2021-09-06 17:36:22 +02:00
parent 218cf81922
commit bb8bee0304
2 changed files with 19 additions and 0 deletions

View File

@ -19,6 +19,7 @@ use App\Models\Document;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Project;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
@ -78,6 +79,10 @@ class DocumentsTable extends Component
$this->query = $this->payments();
break;
case 'projects':
$this->query = $this->projects();
break;
default:
$this->query = $this->documents();
break;
@ -120,4 +125,12 @@ class DocumentsTable extends Component
$query->where('client_id', $this->client->id);
});
}
protected function projects()
{
return Document::query()
->whereHasMorph('documentable', [Project::class], function ($query) {
$query->where('client_id', $this->client->id);
});
}
}

View File

@ -29,6 +29,12 @@
wire:click="updateResources('payments')" />
{{ ctrans('texts.payments') }}
</button>
<button
class="button border border-transparent hover:border-gray-600 {{ $tab === 'projects' ? 'border-gray-600' : '' }}"ž
wire:click="updateResources('projects')" />
{{ ctrans('texts.projects') }}
</button>
</div>
<div class="flex items-center justify-between mt-6">