| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Module\Ulogic\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 用户封禁记录
- * *
- * * field start
- * field end
- */
- class UserBans extends Model
- {
- use HasDateTimeFormatter;
- use SoftDeletes;
- protected $table = 'user_bans';
- // attrlist start
- protected $fillable = [
- ];
- // attrlist end
- /**
- * @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();
- }
- }
|