Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace App\Http\Repositories\interfaces;
4
5use App\Http\Models\Auth\User;
6use App\Http\Models\Plans;
7use App\Http\Models\Subscription;
8
9/**
10 * Interface for subscription data access operations.
11 *
12 * This repository abstracts subscription-related database queries,
13 * providing methods to retrieve active subscriptions and plan information.
14 */
15interface ISubscriptionRepository
16{
17    /**
18     * Get the active subscription for a user.
19     *
20     * This method finds the most recent valid subscription for the user,
21     * ordered by created_at DESC, returning the first one that is valid.
22     * This fixes the bug where the first() method could return a deactivated
23     * subscription instead of the newest active one.
24     *
25     * @param  User  $user  The user to get the subscription for
26     * @param  string  $name  The subscription name (default: 'main')
27     * @return Subscription|null The active subscription or null if none found
28     */
29    public function getActiveSubscription(User $user, string $name = 'main'): ?Subscription;
30
31    /**
32     * Get the freemium plan.
33     *
34     * @return Plans The freemium plan
35     */
36    public function getFreemiumPlan(): Plans;
37
38    /**
39     * Get a plan by its identifier.
40     *
41     * @param  string  $identifier  The plan identifier
42     * @return Plans|null The plan or null if not found
43     */
44    public function getPlanByIdentifier(string $identifier): ?Plans;
45}