【发布时间】:2015-05-19 14:21:14
【问题描述】:
我已经安装了 Cmgmyr\Messenger,但是,由于我的 users 表不包含 name 字段,我需要扩展 Thread 模型和可能的其他几个模型。
我需要扩展的方法是:
/**
* Generates a string of participant information
*
* @param null $userId
* @param array $columns
* @return string
*/
public function participantsString($userId=null, $columns=['name'])
{
$selectString = $this->createSelectString($columns);
$participantNames = $this->getConnection()->table('users')
->join('participants', 'users.id', '=', 'participants.user_id')
->where('participants.thread_id', $this->id)
->select($this->getConnection()->raw($selectString));
if ($userId !== null) {
$participantNames->where('users.id', '!=', $userId);
}
$userNames = $participantNames->lists('users.name');
return implode(', ', $userNames);
}
注意到 users.name 文件被调用了吗?这是需要更改为 username 甚至更好的 users.firstname 和 users.lastname 一起。
我需要将其扩展为以下结构:
Modules/
- Email/
- Models/
- Thread.php
我该怎么办?
【问题讨论】:
标签: php laravel-4 models extends extending-classes