1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Repositories\Transformers\Info;
- use App\Repositories\Models\Info\Notice;
- use League\Fractal\TransformerAbstract;
- class NoticeTransformer extends TransformerAbstract
- {
- /**
- * Prepare data to present.
- *
- * @param Notice $notice
- * @return array
- */
- public function transform(Notice $notice)
- {
- if (request()->has('id')) {
- return [
- 'id' => $notice->id,
- 'name' => $notice->name,
- 'description' => $notice->description,
- 'body' => $notice->body,
- 'release_time' => $notice->release_time,
- 'sort' => $notice->sort,
- 'status' => $notice->status,
- 'created_at' => $notice->created_at ? $notice->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- return [
- 'id' => $notice->id,
- 'name' => $notice->name,
- 'description' => $notice->description,
- 'release_time' => $notice->release_time,
- 'sort' => $notice->sort,
- 'status' => $notice->status,
- 'admin' => $notice->admin,
- 'created_at' => $notice->created_at ? $notice->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- }
|