Files
bsh_info/app/common/model/PostFavorite.php
T

60 lines
1.2 KiB
PHP
Raw Normal View History

2025-11-25 15:39:16 +08:00
<?php
namespace app\common\model;
use support\Model;
class PostFavorite extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'post_favorite';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'post_id', 'user_id', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
2025-12-10 10:29:41 +08:00
public function post()
{
return $this->hasOne('app\common\model\Post', 'id', 'post_id');
}
2025-12-17 10:40:58 +08:00
protected function serializeDate(\DateTimeInterface $date)
{
// 此方法决定了模型日期字段序列化时的默认格式
return $date->format('Y-m-d H:i:s');
}
2025-11-25 15:39:16 +08:00
}