diff --git a/app/Models/Reply.php b/app/Models/Reply.php index 5f5fbb0..7841842 100644 --- a/app/Models/Reply.php +++ b/app/Models/Reply.php @@ -11,6 +11,7 @@ namespace App\Models; * @property int user_id * @property int topic_id * @property User user + * @property Topic topic * @package App\Models */ class Reply extends Model diff --git a/app/Transformers/ReplyTransformer.php b/app/Transformers/ReplyTransformer.php index 51a0cf3..f614c8a 100644 --- a/app/Transformers/ReplyTransformer.php +++ b/app/Transformers/ReplyTransformer.php @@ -15,7 +15,7 @@ use League\Fractal\TransformerAbstract; class ReplyTransformer extends TransformerAbstract { - protected $availableIncludes = ['user']; + protected $availableIncludes = ['user', 'topic']; 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) { return $this->item($reply->user, new UserTransformer());