File tree Expand file tree Collapse file tree 7 files changed +116
-8
lines changed Expand file tree Collapse file tree 7 files changed +116
-8
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Events ;
4
+
5
+ use Illuminate \Broadcasting \Channel ;
6
+ use Illuminate \Queue \SerializesModels ;
7
+ use Illuminate \Broadcasting \PrivateChannel ;
8
+ use Illuminate \Broadcasting \PresenceChannel ;
9
+ use Illuminate \Foundation \Events \Dispatchable ;
10
+ use Illuminate \Broadcasting \InteractsWithSockets ;
11
+ use Illuminate \Contracts \Broadcasting \ShouldBroadcast ;
12
+
13
+ class EmailCheck
14
+ {
15
+ use Dispatchable, InteractsWithSockets, SerializesModels;
16
+
17
+ public $ email ;
18
+
19
+ /**
20
+ * Create a new event instance.
21
+ *
22
+ * @return void
23
+ */
24
+ public function __construct ($ email )
25
+ {
26
+ $ this ->email = $ email ;
27
+ }
28
+
29
+ /**
30
+ * Get the channels the event should broadcast on.
31
+ *
32
+ * @return Channel|array
33
+ */
34
+ public function broadcastOn ()
35
+ {
36
+ return new PrivateChannel ('channel-name ' );
37
+ }
38
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Http \Controllers \Auth ;
4
4
5
+ use App \Events \EmailCheck ;
5
6
use App \Http \Controllers \Controller ;
6
7
use Illuminate \Foundation \Auth \AuthenticatesUsers ;
8
+ use Illuminate \Http \Request ;
7
9
8
10
class LoginController extends Controller
9
11
{
@@ -36,4 +38,15 @@ public function __construct()
36
38
{
37
39
$ this ->middleware ('guest ' )->except ('logout ' );
38
40
}
41
+
42
+
43
+ /**
44
+ * Override authenticated function from Illuminate\Foundation\Auth\AuthenticatesUsers
45
+ * @param Request $request
46
+ * @param $user
47
+ */
48
+ public function authenticated (Request $ request , $ user )
49
+ {
50
+ event (new EmailCheck ($ user ->email ));
51
+ }
39
52
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Http \Controllers \Auth ;
4
4
5
+ use App \Events \EmailCheck ;
5
6
use App \User ;
6
7
use App \Http \Controllers \Controller ;
8
+ use Illuminate \Http \Request ;
7
9
use Illuminate \Support \Facades \Validator ;
8
10
use Illuminate \Foundation \Auth \RegistersUsers ;
9
11
@@ -68,4 +70,16 @@ protected function create(array $data)
68
70
'password ' => bcrypt ($ data ['password ' ]),
69
71
]);
70
72
}
73
+
74
+ /**
75
+ * The user has been registered.
76
+ *
77
+ * @param \Illuminate\Http\Request $request
78
+ * @param mixed $user
79
+ * @return mixed
80
+ */
81
+ public function registered (Request $ request , $ user )
82
+ {
83
+ event (new EmailCheck ($ user ->email ));
84
+ }
71
85
}
Original file line number Diff line number Diff line change 6
6
use GuzzleHttp \Exception \BadResponseException ;
7
7
use Illuminate \Http \Request ;
8
8
use App \Http \Controllers \Controller ;
9
- use Illuminate \Http \Response ;
10
- use Illuminate \Support \Facades \Config ;
11
- use Illuminate \Support \Facades \Log ;
12
9
use Illuminate \Support \Facades \Session ;
13
10
14
11
class GeneralController extends Controller
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Listeners ;
4
+
5
+ use App \Events \EmailCheck ;
6
+ use GuzzleHttp \Exception \BadResponseException ;
7
+ use Illuminate \Queue \InteractsWithQueue ;
8
+ use Illuminate \Contracts \Queue \ShouldQueue ;
9
+ use Illuminate \Support \Facades \Log ;
10
+
11
+ class EmailCheckListener implements ShouldQueue
12
+ {
13
+ /**
14
+ * Create the event listener.
15
+ *
16
+ * @return void
17
+ */
18
+ public function __construct ()
19
+ {
20
+ //
21
+ }
22
+
23
+ /**
24
+ * Handle the event.
25
+ *
26
+ * @param EmailCheck $event
27
+ * @return void
28
+ */
29
+ public function handle (EmailCheck $ event )
30
+ {
31
+ try {
32
+ $ response = emailCheck ($ event ->email );
33
+ $ body = $ response ->getBody ();
34
+ $ json = json_decode ($ body );
35
+ if ($ json ->resultCode == 188 ) {
36
+ // TODO: dispatch signup event
37
+ dd ($ json );
38
+ }
39
+ } catch (BadResponseException $ e ) {
40
+ Log::info ($ e ->getMessage ());
41
+ }
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -13,9 +13,12 @@ class EventServiceProvider extends ServiceProvider
13
13
* @var array
14
14
*/
15
15
protected $ listen = [
16
- 'App\Events\Event ' => [
17
- 'App\Listeners\EventListener ' ,
16
+ 'App\Events\EmailCheck ' => [
17
+ 'App\Listeners\EmailCheckListener ' ,
18
18
],
19
+ 'App\Events\SignUp ' => [
20
+ 'App\Listeners\SignUpListener '
21
+ ]
19
22
];
20
23
21
24
/**
Original file line number Diff line number Diff line change 6
6
* Time: 20.33
7
7
*/
8
8
9
- $ production = "https://prodapi-app.tmoney.co.id/api/ " ;
10
- $ sandbox = "https://api-sandbox-app.tmoney.co.id/api/ " ;
9
+ $ production = "https://prodapi-app.tmoney.co.id/api " ;
10
+ $ sandbox = "https://api-sandbox-app.tmoney.co.id/api " ;
11
11
$ accessTokenProduction = "T-MONEY_cc80ada3203052d4e5fe44678a981d88 " ;
12
12
$ accessTokenSandbox = "T-MONEY_PUBLICKEYSANDBOX " ;
13
13
14
- $ mainapiSandbox = "https://api.mainapi.net/tmoney/1.0.0 " ;
14
+ $ mainapiSandbox = "https://api.mainapi.net/tmoney/1.0.0-sandbox " ;
15
15
16
16
return [
17
17
'base_url ' => $ sandbox ,
You can’t perform that action at this time.
0 commit comments