From f94a5389c439d1d7c236ca33333eb3ad547e3994 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 8 Oct 2021 21:59:47 +0800 Subject: [PATCH] list companies without confirmed payments --- .../Eloquent/Filters/WithOutTransactions.php | 20 +++++++++++++ .../Filters/WithoutConfirmedPayments.php | 24 ++++++++++++++++ app/Models/Company.php | 12 ++++++++ composer.json | 5 ++-- resources/views/pages/settings.blade.php | 28 ++++++++++++++++++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/WithOutTransactions.php create mode 100644 app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php diff --git a/app/Classes/General/Eloquent/Filters/WithOutTransactions.php b/app/Classes/General/Eloquent/Filters/WithOutTransactions.php new file mode 100644 index 00000000..3b551f65 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithOutTransactions.php @@ -0,0 +1,20 @@ +whereDoesntHave('transactions'); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php b/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php new file mode 100644 index 00000000..e17ed5da --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithoutConfirmedPayments.php @@ -0,0 +1,24 @@ +whereDoesntHave('transactions', function($transaction){ + return $transaction->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + }); + } +} \ No newline at end of file diff --git a/app/Models/Company.php b/app/Models/Company.php index c1a6a191..1922fa10 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -12,6 +12,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Collection; +use Staudenmeir\EloquentHasManyDeep\HasManyDeep; +use Staudenmeir\EloquentHasManyDeep\HasRelationships; + /** * Class Company @@ -27,6 +30,7 @@ use Illuminate\Support\Collection; */ class Company extends AbstractModel implements Documentable { + use HasRelationships; use SoftDeletes; protected $table = 'companies'; @@ -90,6 +94,14 @@ class Company extends AbstractModel implements Documentable return $this->HasMany(Booking::class, 'company_id'); } + /** + * @return hasManyDeep + */ + public function transactions(): hasManyDeep + { + return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'booking_id'], ['id', 'id']); + } + /** * @return Builder */ diff --git a/composer.json b/composer.json index 7c7d11ba..377c8932 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.2.5", "ext-fileinfo": "*", "ext-json": "^1.6", + "ext-zip": "*", "barryvdh/laravel-dompdf": "^0.9.0", "carlos-meneses/laravel-mpdf": "^2.1", "fideloper/proxy": "^4.2", @@ -23,8 +24,8 @@ "rinvex/countries": "^6.1", "spatie/laravel-activitylog": "^3.14", "spatie/laravel-permission": "^3.17", - "tymon/jwt-auth": "^1.0", - "ext-zip": "*" + "staudenmeir/eloquent-has-many-deep": "^1.7", + "tymon/jwt-auth": "^1.0" }, "require-dev": { "facade/ignition": "^2.0", diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index edb38329..b7f03a6b 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -522,7 +522,7 @@
-
+
+
+
+
+
+
+ +
+
+
+
+
Leads
+
+
+
+
+
@@ -547,6 +566,13 @@
+
+ + + +