1234567891011121314151617181920212223242526272829 |
- <?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,
- 'created_at' => $notice->created_at ? $notice->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- return [
- 'id' => $notice->id,
- 'created_at' => $notice->created_at ? $notice->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- }
|