diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 1e07412eda4c..a1f522168e69 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -183,6 +183,48 @@ class InvoiceFilters extends QueryFilters ->where('client_id', $this->decodePrimaryKey($client_id)); } + + /** + * @param string $date + * @return Builder + * @throws InvalidArgumentException + */ + public function date(string $date = ''): Builder + { + if (strlen($date) == 0) { + return $this->builder; + } + + if (is_numeric($date)) { + $created_at = Carbon::createFromTimestamp((int)$date); + } else { + $created_at = Carbon::parse($date); + } + + return $this->builder->where('date', '>=', $date); + } + + /** + * @param string $date + * @return Builder + * @throws InvalidArgumentException + */ + public function due_date(string $date = ''): Builder + { + if (strlen($date) == 0) { + return $this->builder; + } + + if (is_numeric($date)) { + $created_at = Carbon::createFromTimestamp((int)$date); + } else { + $created_at = Carbon::parse($date); + } + + return $this->builder->where('due_date', '>=', $date); + } + + /** * Sorts the list based on $sort. * diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index aaf9bf65cbfe..2e1272e5e896 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -25,6 +25,7 @@ use App\Models\Subscription; use App\Repositories\ClientContactRepository; use App\Repositories\ClientRepository; use App\Utils\Number; +use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; @@ -34,6 +35,7 @@ use Livewire\Component; class BillingPortalPurchasev2 extends Component { + use MakesHash; /** * Random hash generated by backend to handle the tracking of state. * @@ -422,6 +424,7 @@ class BillingPortalPurchasev2 extends Component $client_repo = new ClientRepository(new ClientContactRepository()); $data = [ 'name' => '', + 'group_id' => $this->encodePrimaryKey($this->subscription->group_id), 'contacts' => [ ['email' => $this->email], ],