使用 illuminate/database 之后
通過命令 php webman make:model AuthRole 生成的model
如圖:
查詢語句:
$role = AuthRole::where(['status'=>1])->pluck('name','id');
報錯:
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
請問在model 里面不主動寫 protected $table = 'auth_role'; 的情況下,如何去除表名自帶的s呢?
弄個基類,重寫getTable()
https://github.com/wen-gg/webman-laravel-base/blob/main/src/Triats/BModelTrait.php