2
2
3
3
namespace ProtoneMedia \LaravelVerifyNewEmail ;
4
4
5
+ use Illuminate \Database \Eloquent \Model ;
5
6
use Illuminate \Support \Facades \Mail ;
6
7
use Illuminate \Support \Facades \Password ;
7
- use ProtoneMedia \LaravelVerifyNewEmail \Mail \VerifyNewEmail ;
8
8
9
9
trait MustVerifyNewEmail
10
10
{
@@ -14,15 +14,15 @@ trait MustVerifyNewEmail
14
14
* to the new email address.
15
15
*
16
16
* @param string $email
17
- * @return \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail |null
17
+ * @return \Illuminate\Database\Eloquent\Model |null
18
18
*/
19
- public function newEmail (string $ email ):?PendingUserEmail
19
+ public function newEmail (string $ email ):?Model
20
20
{
21
21
if ($ this ->getEmailForVerification () === $ email && $ this ->hasVerifiedEmail ()) {
22
22
return null ;
23
23
}
24
24
25
- return $ this ->createPendingUserEmailModel ($ email )->tap (function (PendingUserEmail $ model ) {
25
+ return $ this ->createPendingUserEmailModel ($ email )->tap (function ($ model ) {
26
26
$ this ->sendPendingEmailVerificationMail ($ model );
27
27
});
28
28
}
@@ -31,13 +31,13 @@ public function newEmail(string $email):?PendingUserEmail
31
31
* Createsa new PendingUserModel model for the given email.
32
32
*
33
33
* @param string $email
34
- * @return \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail
34
+ * @return \Illuminate\Database\Eloquent\Model
35
35
*/
36
- public function createPendingUserEmailModel (string $ email ): PendingUserEmail
36
+ public function createPendingUserEmailModel (string $ email ): Model
37
37
{
38
38
$ this ->clearPendingEmail ();
39
39
40
- return PendingUserEmail:: create ([
40
+ return app ( config ( ' verify-new-email.model ' ))-> create ([
41
41
'user_type ' => get_class ($ this ),
42
42
'user_id ' => $ this ->getKey (),
43
43
'email ' => $ email ,
@@ -52,7 +52,7 @@ public function createPendingUserEmailModel(string $email): PendingUserEmail
52
52
*/
53
53
public function getPendingEmail ():?string
54
54
{
55
- return PendingUserEmail:: forUser ($ this )->value ('email ' );
55
+ return app ( config ( ' verify-new-email.model ' ))-> forUser ($ this )->value ('email ' );
56
56
}
57
57
58
58
/**
@@ -62,16 +62,16 @@ public function getPendingEmail():?string
62
62
*/
63
63
public function clearPendingEmail ()
64
64
{
65
- PendingUserEmail:: forUser ($ this )->get ()->each ->delete ();
65
+ app ( config ( ' verify-new-email.model ' ))-> forUser ($ this )->get ()->each ->delete ();
66
66
}
67
67
68
68
/**
69
69
* Sends the VerifyNewEmail Mailable to the new email address.
70
70
*
71
- * @param \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail $pendingUserEmail
71
+ * @param \Illuminate\Database\Eloquent\Model $pendingUserEmail
72
72
* @return mixed
73
73
*/
74
- public function sendPendingEmailVerificationMail (PendingUserEmail $ pendingUserEmail )
74
+ public function sendPendingEmailVerificationMail (Model $ pendingUserEmail )
75
75
{
76
76
$ mailableClass = config ('verify-new-email.mailable_for_first_verification ' );
77
77
@@ -87,11 +87,11 @@ public function sendPendingEmailVerificationMail(PendingUserEmail $pendingUserEm
87
87
/**
88
88
* Grabs the pending user email address, generates a new token and sends the Mailable.
89
89
*
90
- * @return \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail |null
90
+ * @return \Illuminate\Database\Eloquent\Model |null
91
91
*/
92
- public function resendPendingEmailVerificationMail ():?PendingUserEmail
92
+ public function resendPendingEmailVerificationMail ():?Model
93
93
{
94
- $ pendingUserEmail = PendingUserEmail:: forUser ($ this )->firstOrFail ();
94
+ $ pendingUserEmail = app ( config ( ' verify-new-email.model ' ))-> forUser ($ this )->firstOrFail ();
95
95
96
96
return $ this ->newEmail ($ pendingUserEmail ->email );
97
97
}
0 commit comments