Skip to content

Commit

Permalink
Model 中使用相应的 protected 属性自定义数据库连接服务名称、表名、主键
Browse files Browse the repository at this point in the history
  • Loading branch information
ueaner committed Sep 13, 2018
1 parent 9dbe71d commit 7603a03
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@

class User extends Model
{
public function tableName()
{
return 'user';
}
/**
* 当前模型访问的数据库连接服务名称
*/
protected $connection = 'db';

/**
* 当前模型操作的表名
*/
protected $table = 'user';

/**
* 当前模型所操作表的主键
*/
protected $primaryKey = 'id';
}

0 comments on commit 7603a03

Please sign in to comment.