public $table = 'posts'; //设置主键 //public $primaryKey = 'id'; //$dates属性里面包含的字段可以直接后面跟carbon类时间操作的任何方法,例如一个模型: protected $dates = ['delete_at']; protected $table = 'users'; public $primaryKey = 'uid'; /*$attributes属性 默认给数据库里的一个字段赋值*/ protected $attributes = [ 'user_limit' => 100, ]; /** * The attributes that are mass assignable. * * @var array */ //表示可以用create批量赋值的列 protected $fillable = ['name', 'email', 'password']; //不可以操作的字段 protected $guarded = []; /** * The attributes excluded from the model's JSON form. * * @var array */ //隐藏的字段 protected $hidden = ['password', 'remember_token'];
model的约定
最新推荐文章于 2021-07-15 16:51:04 发布