依赖 composer.json
{ "require": { "php": "^8.0.2", "laravel/framework": "^9.19" } }
自定义的Model
class ArticleModel extends BaseModel { protected string $table = 'tb_article'; }
同样的代码,在本地测试环境中可以运行,上线后就报错
可能的报错如下
$table must not be defined (as in class Illuminate\\Database\\Eloquent\\Model) $table must be string (as in class Illuminate\\Database\\Eloquent\\Model)
把类型标注去掉,修改如下
class ArticleModel extends BaseModel { protected $table = 'tb_article'; }
参考
$fillable must not be defined (as in class Illuminate\Database\Eloquent\Model) in laravel