Skip to content

Commit cfc218f

Browse files
authored
Merge pull request #4301 from HDInnovations/Bug-4277
2 parents 6665f3e + 98b7bad commit cfc218f

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

app/Http/Controllers/Staff/DonationController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function index(Request $request): \Illuminate\Contracts\View\View|\Illumi
3434
{
3535
abort_unless($request->user()->group->is_owner, 403);
3636

37-
$donations = Donation::with('package')->latest()->paginate(25);
37+
$donations = Donation::with(['package' => function ($query): void {
38+
$query->withTrashed();
39+
}])->latest()->paginate(25);
3840

3941
$dailyDonations = Donation::selectRaw('DATE(donations.created_at) as date, SUM(donation_packages.cost) as total')
4042
->join('donation_packages', 'donations.package_id', '=', 'donation_packages.id')

app/Models/Donation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
9696
*/
9797
public function package(): \Illuminate\Database\Eloquent\Relations\BelongsTo
9898
{
99-
return $this->belongsTo(DonationPackage::class);
99+
return $this->belongsTo(DonationPackage::class)->withTrashed();
100100
}
101101
}

app/Models/DonationPackage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Illuminate\Database\Eloquent\Factories\HasFactory;
2020
use Illuminate\Database\Eloquent\Model;
21+
use Illuminate\Database\Eloquent\SoftDeletes;
2122

2223
/**
2324
* App\Models\DonationPackage.
@@ -39,6 +40,7 @@ class DonationPackage extends Model
3940
{
4041
/** @use HasFactory<\Database\Factories\DonationPackagefactory> */
4142
use HasFactory;
43+
use SoftDeletes;
4244

4345
/**
4446
* The attributes that aren't mass assignable.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\Schema;
8+
9+
return new class () extends Migration {
10+
public function up(): void
11+
{
12+
Schema::table('donation_packages', function (Blueprint $table): void {
13+
$table->softDeletes()->after('updated_at');
14+
});
15+
}
16+
};

resources/views/Staff/donation/index.blade.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,34 @@
5252
<x-user_tag :user="$donation->user" :anon="false" />
5353
</td>
5454
<td>{{ $donation->transaction }}</td>
55-
<td>$ {{ $donation->package->cost }}</td>
56-
<td>
55+
<td
56+
class="{{ $donation->package->trashed() ? 'text-danger' : '' }}"
57+
title="{{ $donation->package->trashed() ? 'Package has been deleted' : '' }}"
58+
>
59+
$ {{ $donation->package->cost }}
60+
</td>
61+
<td
62+
class="{{ $donation->package->trashed() ? 'text-danger' : '' }}"
63+
title="{{ $donation->package->trashed() ? 'Package has been deleted' : '' }}"
64+
>
5765
{{ App\Helpers\StringHelper::formatBytes($donation->package->upload_value ?? 0) }}
5866
</td>
59-
<td>{{ $donation->package->invite_value ?? 0 }}</td>
60-
<td>{{ $donation->package->bonus_value ?? 0 }}</td>
61-
<td>
67+
<td
68+
class="{{ $donation->package->trashed() ? 'text-danger' : '' }}"
69+
title="{{ $donation->package->trashed() ? 'Package has been deleted' : '' }}"
70+
>
71+
{{ $donation->package->invite_value ?? 0 }}
72+
</td>
73+
<td
74+
class="{{ $donation->package->trashed() ? 'text-danger' : '' }}"
75+
title="{{ $donation->package->trashed() ? 'Package has been deleted' : '' }}"
76+
>
77+
{{ $donation->package->bonus_value ?? 0 }}
78+
</td>
79+
<td
80+
class="{{ $donation->package->trashed() ? 'text-danger' : '' }}"
81+
title="{{ $donation->package->trashed() ? 'Package has been deleted' : '' }}"
82+
>
6283
@if ($donation->package->donor_value === null)
6384
Lifetime
6485
@else

0 commit comments

Comments
 (0)