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