AreaTransformer.php 1.6 KB
<?php
/**
 * +-----------------------------------------------------------------------------------------------------------------------
 * 数据转换层: 系统区域 转换类
 * +-----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Transformers
 * @package   App\Transformers
 * @author    Richer <yangzi1028@163.com>
 * @date      2021年7月1日15:42:25
 * @copyright 2021-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Transformers\System;

use App\Models\Area\Area;
use App\Transformers\BaseTransformer;
use Illuminate\Support\Arr;

/**
 * Class AreaTransformer
 *
 * @category  App\Transformers
 * @package   App\Transformers
 * @author    Richer <yangzi1028@163.com>
 * @date      2021年7月1日15:42:25
 * @copyright 2021-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
class AreaTransformer extends BaseTransformer
{

    public function transform(Area $model)
    {
        return [

            'id'    => (int) $model->id,

            /* place your other model properties here */
            'name'  => (string)$model->name,
//            'initial'     => (string)$model->initial,
//            'pinyin' => (string)$model->pinyin,
            'sort'    => (int) $model->sort,
            'status'    => (int) $model->status,
            'created_at' => format_date($model->created_at),
        ];
    }
}