| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Module\Ulogic\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 用户封禁记录
- * *
- * * field start
- * * @property int $id 主键id
- * * @property int $user_id 用户id
- * * @property int $type 封禁类型
- * * @property int $admin_id 操作人
- * * @property int $end_time 封禁结束时间
- * * @property string $created_at
- * * @property string $updated_at
- * * @property string $deleted_at
- * * field end
- */
- class UserBans extends Model
- {
- use HasDateTimeFormatter;
- use SoftDeletes;
- protected $table = 'user_bans';
- /**
- * @param $userId
- * @param $type
- * @param $adminId
- * @param $endTime
- * @return bool
- * 用户封禁
- */
- public static function create($userId, $type, $adminId = 0, $endTime = 0)
- {
- $model = new self();
- $model->user_id = $userId;
- $model->type = $type;
- $model->admin_id = $adminId;
- $model->end_time = $endTime;
- return $model->save();
- }
- /**
- * @param $userId
- * @param $type
- * @return null
- * 获取封禁信息
- */
- public static function getRow($userId, $type)
- {
- $query = self::query();
- $query->where(['user_id' => $userId, 'type' => $type]);
- if ($type == 1) {
- $query->where('end_time', '>', time());
- }
- return $query->first();
- }
- }
|