LoginLogic.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace App\Http\Logic\Aside;
use App\Models\Manage\Manage;
use App\Models\Manage\LoginLog;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Session;
/**
* Class LoginLogic
* @package App\Http\Logic\Aside
* @author zbj
* @date 2023/4/19
*/
class LoginLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Manage();
}
public function login()
{
$manage = $this->model->where('mobile', $this->requestAll['mobile'])->first();
if (!$manage){
$this->fail('登录用户名不存在');
}
if (Manage::STATUS_DISABLE == $manage->status) {
$this->fail('帐号已被禁用');
}
if (!Hash::check($this->requestAll['password'], $manage->password)) {
$this->fail('登录密码不正确');
}
Session::put('manage', $manage->toArray());
LoginLog::addLog($manage->id);
return $this->success();
}
public function logout(){
Session::forget('manage');
return redirect(route('admin.login'));
}
public static function manage($field = ''){
$manage = Session::get('manage');
$manage = Manage::find(1)->toArray();
if($field){
return $manage[$field] ?? '';
}
return $manage;
}
}