File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1616class User
1717{
1818 use UsesRoles;
19+ use UsesSubscriptions;
1920
2021 /**
2122 * Internal instance of Leaf database
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Leaf \Auth ;
4+
5+ /**
6+ * Functionality for user subscriptions
7+ * ----
8+ * Addition to user class
9+ *
10+ * @version 0.1.0
11+ * @since 4.1.0
12+ */
13+ trait UsesSubscriptions
14+ {
15+ /**
16+ * User Subscription
17+ * @var array|null
18+ */
19+ protected $ subscription = null ;
20+
21+ /**
22+ * Get current subscription
23+ *
24+ * @param string|array $subscription The subscription to assign
25+ * @return array|null
26+ */
27+ public function subscription ()
28+ {
29+ if (!$ this ->subscription ) {
30+ $ this ->subscription = db ()
31+ ->select ('subscriptions ' )
32+ ->where ('user_id ' , $ this ->id ())
33+ ->first ();
34+
35+ $ this ->subscription ['tier ' ] = billing ()->tier ($ this ->subscription ['plan_id ' ]);
36+ }
37+
38+ return $ this ->subscription ;
39+ }
40+
41+ }
You can’t perform that action at this time.
0 commit comments