123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Repositories\Transformers\Base;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\App;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\Base\Menu;
- /**
- * Class MenuTransformer.
- *
- * @package namespace App\Repositories\Transformers\Base;
- */
- class MenuTransformer extends TransformerAbstract
- {
- /**
- * Transform the Menu entity.
- *
- * @param \App\Repositories\Models\Base\Menu $model
- *
- * @return array
- */
- public function transform(Menu $model)
- {
- return [
- 'id' => (int)$model->id,
- 'parent_id' => $model->parent_id,
- 'parent_name' => $model->parent->name ?? '--',
- 'name' => $model->name,
- 'zh_title' => $model->zh_title,
- 'en_title' => $model->en_title,
- 'path' => $model->path,
- 'component' => $model->component,
- 'redirect' => $model->redirect,
- 'meta' => $model->meta,
- 'sort' => $model->sort,
- 'status' => $model->status,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|