Recurring invoices

This commit is contained in:
Benjamin Beganović 2021-09-06 17:38:45 +02:00
parent d5326f4873
commit f179831e06
2 changed files with 20 additions and 1 deletions

View File

@ -21,6 +21,7 @@ use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Project;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
@ -88,6 +89,10 @@ class DocumentsTable extends Component
$this->query = $this->quotes();
break;
case 'recurringInvoices':
$this->query = $this->recurringInvoices();
break;
default:
$this->query = $this->documents();
break;
@ -146,4 +151,12 @@ class DocumentsTable extends Component
$query->where('client_id', $this->client->id);
});
}
protected function recurringInvoices()
{
return Document::query()
->whereHasMorph('documentable', [RecurringInvoice::class], function ($query) {
$query->where('client_id', $this->client->id);
});
}
}

View File

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