0

我已经安装了 Cmgmyr\Messenger,但是,我需要扩展 Thread 模型和可能的其他几个模型,因为我的 users 表不包含name字段。

我需要扩展的方法是:

/**
     * 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

我该怎么办?

4

1 回答 1

0

最简单的方法是在 github 上 fork 包,自己对包进行更改,然后在 composer 上拉入您的自定义包(而不是原始包)。

这样,您就可以控制对另一个包的更改。

此处介绍了拉入 fork 的具体方法: How to require a fork with composer

于 2015-05-19T14:25:13.350 回答