12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Repositories\Transformers\Inform;
- use App\Repositories\Transformers\BaseTransformer;
- use Carbon\Carbon;
- /**
- * Class InformationTransformer.
- *
- * @package namespace App\Repositories\Transformers\Inform;
- */
- class InformationTransformer extends BaseTransformer
- {
- public function lists($model)
- {
- return [
- 'id' => (int)$model->id,
- 'title' => $model->title,
- // 'category_id' => $model->category_id,
- 'category' => $model->category,
- // 'cover' => $model->cover,
- 'cover_resource' => $model->cover_resource,
- // 'short_description' => $model->short_description,
- 'tags' => $model->tags,
- 'slug' => $model->slug,
- "body" => mb_substr(strip_tags($model->body), 0, 200, 'utf-8'),
- 'published_at' => $model->published_at,
- // 'is_message' => $model->is_message,
- 'view_count' => $model->view_count,
- 'good_count' => $model->good_count,
- // 'sort' => $model->sort,
- // 'status' => $model->status,
- 'admin' => $model->admin,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'humans' => $model->created_at->diffForHumans(),
- ];
- }
- public function detail($model)
- {
- return [
- 'id' => (int)$model->id,
- 'title' => $model->title,
- // 'category_id' => $model->category_id,
- // 'category_name' => $model->category,
- // 'cover' => $model->cover,
- 'cover_resource' => $model->cover_resource,
- // 'short_description' => $model->short_description,
- 'tags' => $model->tags,
- 'slug' => $model->slug,
- 'body' => $model->body,
- 'published_at' => $model->published_at,
- // 'is_message' => $model->is_message,
- 'view_count' => $model->view_count,
- 'good_count' => $model->good_count,
- 'sort' => $model->sort,
- 'status' => $model->status,
- 'admin_name' => $model->admin,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'humans' => $model->created_at->diffForHumans(),
- ];
- }
- }
|