laravel如何判断模型中是否有指定字段

2023-11-16 10:26:20
243

比如,需要判断模型中是否有user_id字段,用以下方法即可。

 

Schema::hasColumn($this->model->getTable(), 'user_id')