使用 illuminate/database 之后
通過(guò)命令 php webman make:model AuthRole 生成的model
如圖:
查詢(xún)語(yǔ)句:
$role = AuthRole::where(['status'=>1])->pluck('name','id');
報(bào)錯(cuò):
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wxshop.auth_roles' doesn't exist in /xxxxx/vendor/illuminate/database/Connection.php:368
請(qǐng)問(wèn)在model 里面不主動(dòng)寫(xiě) protected $table = 'auth_role'; 的情況下,如何去除表名自帶的s呢?
弄個(gè)基類(lèi),重寫(xiě)getTable()
https://github.com/wen-gg/webman-laravel-base/blob/main/src/Triats/BModelTrait.php