Skip to content

Commit a441d15

Browse files
committed
用户登录事件
1 parent 4cff6b0 commit a441d15

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Api/Api.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Jason\Api;
44

55
use Illuminate\Support\Facades\Auth;
6+
use Jason\Api\Events\ApiLogin;
67

78
class Api
89
{
@@ -56,6 +57,7 @@ public function attempt(array $credentials)
5657
*/
5758
public function login($user)
5859
{
60+
event(new ApiLogin($user));
5961
return Auth::guard(self::GUARD)->login($user);
6062
}
6163

src/Api/Events/ApiLogin.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Jason\Api\Events;
4+
5+
use Illuminate\Foundation\Events\Dispatchable;
6+
7+
class ApiLogin
8+
{
9+
10+
use Dispatchable;
11+
12+
public $user;
13+
14+
/**
15+
* 创建一个事件实例
16+
* @return void
17+
*/
18+
public function __construct($user)
19+
{
20+
$this->user = $user;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)