Installer.php 1.04 KB
Newer Older
冯超鹏's avatar
冯超鹏 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
namespace App\Laravue\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class Installer extends Authenticatable
{
    use Notifiable, HasRoles, HasApiTokens;
    protected $table = "installer";
    public $timestamps = false;
    //添加装维人员
    public function addinstall($data = []) : string {
冯超鹏's avatar
冯超鹏 committed
16
        $stringrand = $this->numsigng();
冯超鹏's avatar
冯超鹏 committed
17 18 19 20 21
        foreach ($data as $k => $value) {
            if (is_null($k)) {
                return '用户提交表单参数错误';
            }
        }
冯超鹏's avatar
冯超鹏 committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35
        $data['addtime'] = time();
        $data['password'] = md5(md5($data['password']) . $stringrand);
        $data['salt'] = $stringrand;
        return $this->insertGetId($data);
    }

    //生成随机字符串
    private function numsigng() : int{
        $code = '';
        for ($i=1;$i<7;$i++) {
            $randcode = mt_rand(0,9);
            $code .= $randcode;
        }
        return (int)$code;
冯超鹏's avatar
冯超鹏 committed
36 37
    }
}