回复列表

This commit is contained in:
fthvgb1 2018-06-10 22:40:18 +08:00
parent 200fbdfc0a
commit b27ddbbe7d
2 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,7 @@ namespace App\Models;
* @property int user_id * @property int user_id
* @property int topic_id * @property int topic_id
* @property User user * @property User user
* @property Topic topic
* @package App\Models * @package App\Models
*/ */
class Reply extends Model class Reply extends Model

View File

@ -15,7 +15,7 @@ use League\Fractal\TransformerAbstract;
class ReplyTransformer extends TransformerAbstract class ReplyTransformer extends TransformerAbstract
{ {
protected $availableIncludes = ['user']; protected $availableIncludes = ['user', 'topic'];
public function transform(Reply $reply) public function transform(Reply $reply)
{ {
@ -29,6 +29,11 @@ class ReplyTransformer extends TransformerAbstract
]; ];
} }
public function includeTopic(Reply $reply)
{
return $this->item($reply->topic, new TopicTransformer());
}
public function includeUser(Reply $reply) public function includeUser(Reply $reply)
{ {
return $this->item($reply->user, new UserTransformer()); return $this->item($reply->user, new UserTransformer());