| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- declare(strict_types=1);
- namespace SixShop\Points\Model;
- use app\model\User;
- use SixShop\Points\Enum\UserPointTypeEnum;
- use think\db\Query;
- use think\Model;
- use think\model\relation\BelongsTo;
- class UserPointLogModel extends Model
- {
- protected function getOptions(): array
- {
- return [
- 'name' => 'extension_user_point_log',
- 'type' => [
- 'type' => UserPointTypeEnum::class,
- ]
- ];
- }
- public function user(): BelongsTo
- {
- return $this->belongsTo(User::class, 'user_id', 'id');
- }
- public function searchUserIdAttr(Query $query, $value, $data)
- {
- $value > 0 && $query->where('user_id', $value);
- }
- public function searchTypeAttr(Query $query, $value, $data)
- {
- $value > 0 && $query->where('type', $value);
- }
- public function searchCreateTimeAttr(Query $query, $value, $data)
- {
- $value && $query->whereBetweenTime('create_time', $value[0], $value[1]);
- }
- }
|