123456789101112131415161718192021222324252627282930 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/17
- * Time: 18:10
- */
- namespace App\Transformers\Topic;
- use App\Models\Topic;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- class TopicDetailTransformer extends TransformerAbstract
- {
- public function __construct($uid)
- {
- $this->uid = $uid;
- }
- public function transform(Topic $topic)
- {
- return [
- 'id' => $topic['id'],
- 'name' => $topic['name'],
- 'img' => $topic['img'],
- 'follow_count' => $topic->follow->count() + (int) config('customer.add_topic_follow_count'),
- 'is_follow' => $topic->follow->where('uid', $this->uid)->count()?1:0,
- ];
- }
- }
|