123456789101112131415161718192021222324252627282930313233 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/6
- * Time: 14:08
- */
- namespace App\Transformers\Post;
- use App\Models\PostStore;
- use App\Traits\PostTrait;
- use Illuminate\Support\Carbon;
- use League\Fractal\TransformerAbstract;
- class PostStoreTransformer extends TransformerAbstract
- {
- use PostTrait;
- public function transform(PostStore $postStore)
- {
- return [
- 'id' => $postStore['id'],
- 'type' => $postStore['type'],
- 'category_id' => $postStore['category_id'],
- 'source' => $postStore['source'],
- 'title' => $postStore['title'],
- 'content' => subtext($postStore['content'], 20),
- 'img' => $postStore['img'],
- 'is_used' => $postStore['is_used'],
- 'created_at' => Carbon::parse($postStore['created_at'])->toDateTimeString(),
- ];
- }
- }
|