123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace App\Models;
- use Illuminate\Contracts\Auth\MustVerifyEmail;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Foundation\Auth\User as Authenticatable;
- use Illuminate\Notifications\Notifiable;
- use Laravel\Sanctum\HasApiTokens;
- use Tymon\JWTAuth\Contracts\JWTSubject;
- use DateTimeInterface;
- class User extends Authenticatable implements JWTSubject
- {
- use HasApiTokens, HasFactory, Notifiable ,SoftDeletes;
- /**
- * The attributes that are mass assignable.
- *
- * @var array<int, string>
- */
- protected $fillable = [
- ];
- public function getJWTIdentifier()
- {
- return $this->getKey();
- }
- public function getJWTCustomClaims()
- {
- return [];
- }
- /**
- * The attributes that should be hidden for serialization.
- *
- * @var array<int, string>
- */
- protected $hidden = [
- 'password',
- ];
- protected function serializeDate(DateTimeInterface $date)
- {
- return $date->format('Y-m-d H:i:s');
- }
- /**
- * The attributes that should be cast.
- *
- * @var array<string, string>
- */
- protected function Register($data){
- $user=new User();
- $user->mobile=$data['mobile'];
- $user->password=sha1($data['password']);
- $user->person_num='zjb-'.time().rand(1111,9999);
- $user->save();
- return $user;
- }
- /**
- * 后台
- * 后台后台
- *后台后台
- * 后台后台
- *后台后台后台
- *后台后台
- *后台后台
- *后台后台
- ****************/
- //获取用户信息
- protected function UserInfo($data){
- $query=User::query();
- $page_size=$data['page_size'];
- $page_index=$data['page_index'];
- $num=($page_index-1)*$page_size;
- if ($data['search_name']){
- $search_name=$data['search_name'];
- $query->where('mobile','like',"%$search_name%")
- ->orWhere('nickname','like',"%$search_name%");
- }
- $count=$query->count();
- $list=$query->take($page_size)->skip($num)->get();
- return ['list'=>$list,'total'=>$count];
- }
- /**
- * 后台
- * 后台后台
- *后台后台
- ****************/
- //修改用户信息
- protected function UpdateUserInfo($data){
- $id=$data['id'];
- unset($data['id']);
- User::where('id',$id)->update($data);
- }
- //删除用户信息
- protected function DeleteUserInfo($id){
- User::where('id',$id)->delete();
- }
- }
|