1 | <?php |
||
9 | class EloquentRepository extends Model implements SubscriptionRepository |
||
10 | { |
||
11 | use SoftDeletes; |
||
12 | |||
13 | /** |
||
14 | * @var bool |
||
15 | */ |
||
16 | public $timestamps = false; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $dates = [ |
||
22 | 'verified_at', |
||
23 | 'subscribed_at', |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $guarded = []; |
||
30 | |||
31 | /** |
||
32 | * EloquentRepository constructor. |
||
33 | * |
||
34 | * @param array $attributes |
||
35 | */ |
||
36 | public function __construct(array $attributes = []) |
||
42 | |||
43 | /** |
||
44 | * Adds a new subscriber to the repository. |
||
45 | * |
||
46 | * @param string $email |
||
47 | * @param string|null $name |
||
48 | * @return bool |
||
49 | */ |
||
50 | public function addSubscriber(string $email, ?string $name): bool |
||
57 | |||
58 | /** |
||
59 | * Removes a subscriber. |
||
60 | * |
||
61 | * @param string $email |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function removeSubscriber(string $email): bool |
||
70 | |||
71 | /** |
||
72 | * Verify the subscriber. |
||
73 | * |
||
74 | * @param string $email |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function verify(string $email): bool |
||
83 | |||
84 | /** |
||
85 | * Find subscriber by email. |
||
86 | * |
||
87 | * @param string $email |
||
88 | * @return array|false |
||
89 | */ |
||
90 | public function findByEmail(string $email) |
||
96 | |||
97 | /** |
||
98 | * Query by email. |
||
99 | * |
||
100 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
101 | * @param string $email |
||
102 | * @return \Illuminate\Database\Eloquent\Builder |
||
103 | */ |
||
104 | public function scopeByEmail($query, string $email) |
||
108 | } |
||
109 |