<?php
/**
 * Created by PhpStorm.
 * User: zilongs
 * Date: 20-10-5
 * Time: 下午3:37
 */
namespace App\Models;

class DocterMessage extends BaseModel
{
    protected $table='docter_messages';
    public $timestamps = true;

    public static function saveMessage($docter_id, $user_id, $type, $relation_id = 0, $param = [], $content = '')
    {
        if (empty($content)) {
            $content = config('config.docter_message_map')[$type] ?? '';
            $content = vsprintf($content, $param);
        }
        DocterMessage::create([
            'docter_id' => $docter_id,
            'status' => 1,
            'user_id' => $user_id,
            'type' => $type,
            'relation_id' => $relation_id,
            'content' => $content,
        ]);

        return true;
    }
}
