feat(admin): site subscription show page with related platform orders
This commit is contained in:
@@ -9,11 +9,44 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use App\Models\PlatformOrder;
|
||||
|
||||
class SiteSubscriptionController extends Controller
|
||||
{
|
||||
use ResolvesPlatformAdminContext;
|
||||
|
||||
public function show(Request $request, SiteSubscription $subscription): View
|
||||
{
|
||||
$this->ensurePlatformAdmin($request);
|
||||
|
||||
$subscription->loadMissing(['merchant', 'plan']);
|
||||
|
||||
$platformOrders = PlatformOrder::query()
|
||||
->where('site_subscription_id', $subscription->id)
|
||||
->latest('id')
|
||||
->paginate(10)
|
||||
->withQueryString();
|
||||
|
||||
$endsAt = $subscription->ends_at;
|
||||
$expiryLabel = '无到期';
|
||||
if ($endsAt) {
|
||||
if ($endsAt->lt(now())) {
|
||||
$expiryLabel = '已过期';
|
||||
} elseif ($endsAt->lt(now()->addDays(7))) {
|
||||
$expiryLabel = '7天内到期';
|
||||
} else {
|
||||
$expiryLabel = '未到期';
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.site_subscriptions.show', [
|
||||
'subscription' => $subscription,
|
||||
'platformOrders' => $platformOrders,
|
||||
'statusLabels' => $this->statusLabels(),
|
||||
'expiryLabel' => $expiryLabel,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request): StreamedResponse
|
||||
{
|
||||
$this->ensurePlatformAdmin($request);
|
||||
|
||||
Reference in New Issue
Block a user