<?php

namespace App\Models\Artisan;

use App\Core\Model;

/**
 * App\Models\Artisan\Artisan
 *
 * @property int $id
 * @property string $command 命令类型
 * @property array|null $parameters 参数
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read string $command_name
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan whereCommand($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan whereParameters($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Artisan\Artisan whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Artisan extends Model
{
    protected $table = 'artisans';

    protected $casts = [
        'parameters' => 'array',
    ];

    protected $appends = ['command_name'];

    public static $names = [
        'real:sync-added-order'  => '同步RD企业订单数据',
        'real:sync-company'      => '同步RD企业数据',
        'real:sync-mongo'        => '同步卡基础信息数据',
        'real:sync-order'        => '同步RD基础订单数据',
        'real:sync-package'      => '同步RD套餐数据',
        'real:sync-cancelled'    => '同步RD注销数据',
        'real:sync-refund'       => '同步RD退货数据',
        'real:sync-activated'    => '同步RD激活数据',
        'virtual:sync-company'   => '同步VD企业数据',
        'virtual:sync-package'   => '同步VD套餐数据',
        'virtual:sync-product'   => '同步VD定价',
    ];

    /**
     * 获取命令名称
     *
     * @return string
     */
    public function getCommandNameAttribute()
    {
        return self::$names[$this->attributes['command']] ?? '';
    }
}
