4.4.1 创建模型
创建模型
php bin/hyperf.php gen:model table_name
成员属性
<?php
declare (strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property string $merchant_no
* @property string $title
* @property string $desc
* @property int $status
* @property string $meta
* @property string $cdn_addr
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $deleted_at
*/
class UserActivity extends Model
{
/**
* 数据库连接
* @var string
*/
protected $connection = 'default';
/**
* 表名
* @var string
*/
protected $table = 'user_activity';
/**
* 主键
* @var string
*/
protected $primaryKey = 'id';
/**
* 主键类型
* @var string
*/
protected $keyType = 'int';
/**
* 是否是自增主键
* @var bool
*/
public $incrementing = true;
/**
* 允许被批量赋值的属性
* @var array
*/
protected $fillable = ['merchant_no', 'title', 'desc', 'status', 'meta', 'cdn_addr'];
/**
* 数据格式化的配置
* @var string[]
*/
protected $casts = [
'id' => 'integer',
'status' => 'integer',
'meta' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime'
];
/**
* 是否需要自动维护时间戳
* @var bool
*/
public $timestamps = true;
/**
* 自动维护时间的时间格式,时间戳为U
* @var string
*/
protected $dateFormat = 'Y-m-d H:i:s';
/**
* 创建时间
*/
const CREATED_AT = 'created_at';
/**
* 更新时间
*/
const UPDATED_AT = 'updated_at';
/**
* 删除时间,只要在软删除的时候需要用到
*/
const DELETED_AT = 'deleted_at';
}文档更新时间: 2021-09-24 17:37 作者:赵豪