1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Repositories\Transformers\Info;
- use App\Repositories\Models\Info\SearchHistory;
- use League\Fractal\TransformerAbstract;
- class SearchHistoryTransformer extends TransformerAbstract
- {
- /**
- * Prepare data to present.
- *
- * @param SearchHistory $searchHistory
- * @return array
- */
- public function transform(SearchHistory $searchHistory)
- {
- if (request()->has('id')) {
- return [
- 'id' => $searchHistory->id,
- 'created_at' => $searchHistory->created_at ? $searchHistory->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- return [
- 'id' => $searchHistory->id,
- 'created_at' => $searchHistory->created_at ? $searchHistory->created_at->format('Y-m-d H:i:s') : null,
- ];
- }
- }
|