<?php

namespace App\Models\Diary;

use App\Models\User\UserModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\Diary\DiaryModel
 *
 * @property int $id
 * @property int $uid uid
 * @property string $content 内容
 * @property string $images 图片
 * @property int $thumb 点赞数量
 * @property int $private 是否私有
 * @property int $selected_at 精选时间
 * @property int $topped_at 指定时间
 * @property \Illuminate\Support\Carbon $created_at 创建时间
 * @property \Illuminate\Support\Carbon $updated_at 修改时间
 * @property int|null $deleted_at 删除时间
 * @property int|null $violationed_at 违规时间（管理员删除的时间）
 * @property-read \App\Models\User\UserModel $user
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Diary\DiaryModel onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereImages($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel wherePrivate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereSelectedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereThumb($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereToppedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Diary\DiaryModel whereViolationedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Diary\DiaryModel withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Diary\DiaryModel withoutTrashed()
 * @mixin \Eloquent
 */
class DiaryModel extends Model
{
    use SoftDeletes;

    protected $table = "kdgx_fpdx_diarys";

    protected $dateFormat = 'U';

    public $fillable = ['uid', 'content', 'images', 'private', 'thumb', 'violationed_at', 'selected_at', 'topped_at'];


    public function user()
    {
        return $this->belongsTo(UserModel::class, 'uid', 'uid')->select("nickname", "headimgurl");
    }
}
