<?php

namespace App\Models;

use App\Scopes\UserScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\UserSignRecord.
 *
 * @property int                             $id
 * @property int                             $user_id    user_id
 * @property string                          $date       签到时间
 * @property int                             $award      签到奖励
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string|null                     $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 *
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord query()
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereAward($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereDate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord whereUserId($value)
 *
 * @mixin \Eloquent
 *
 * @property \App\Models\User|null $user
 *
 * @method static \Illuminate\Database\Eloquent\Builder|UserSignRecord filterUser()
 */
class UserSignRecord extends Model
{
    use HasFactory;
    use UserScope;

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'id', 'user_id');
    }
}
