LockPasswordTemplate.php 2.1 KB
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
 * 短信模板类:各种业务发送短信的模板
+-----------------------------------------------------------------------------------------------------------------------
 * PHP version 7
 *
 * @category  App\Sms
 * @package   App\Sms
 * @author    Richer <yangzi1028@163.com>
 * @date      2020年6月15日,16:08:39
 * @copyright 2021-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Sms;

use App\Models\Warning;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;

/**
 * Class Template
 *
 * @category  App\Sms
 * @package   App\Sms
 * @author    Richer <yangzi1028@163.com>
 * @date      2020年6月15日,16:08:39
 * @copyright 2021-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
class LockPasswordTemplate
{
    /**
     * 获取消息发送的参数
     *
     * @param Model $model 对象模型
     * @param string $target 发送目标
     * @param string $operate
     * @return array
     */
    public static function getParams($model, $target = 'tenant', $operate = 'tenant')
    {
        $params = [];
        switch ($operate) {
            case 'tenant':
                $params = self::getTenantParams($model, $target);
                break;

        }

        return $params;
    }

    /**
     * @param $model
     * @param $target
     * @return array
     */
    protected static function getTenantParams($model, $target)
    {
        $tenant = $model->$target;
        if (!$tenant) {
            return false;
        }
        return [
            'house' => optional($tenant->village)->title . optional($tenant->group)->title.
                optional($tenant->building)->title . optional($tenant->room)->title,
            'password' => $model->password,
            'start_date' => format_date($model->enabled_at, 'Y-m-d'),
            'end_date' => format_date($model->expired_at, 'Y-m-d'),
        ];
    }
}