<?php

namespace addons\webman\model;

use addons\webman\traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Class ActivityContent
 * @property int id 主键
 * @property string name 活动名称
 * @property int activity_id 活动id
 * @property string lang 语言标识
 * @property string link 链接
 * @property string picture 活动主图
 * @property string created_at 创建时间
 * @property string updated_at 最后一次修改时间
 *
 * @property Activity activity 活动
 * @property ActivityContent activity_content 活动内容
 * @package addons\webman\model
 */
class ActivityContent extends Model
{
    use HasDateTimeFormatter;
    //数据权限字段
    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->setTable(plugin()->webman->config('database.activity_content_table'));
    }

    /**
     * 活动
     * @return BelongsTo
     */
    public function activity(): BelongsTo
    {
        return $this->belongsTo(plugin()->webman->config('database.activity_model'), 'activity_id')->withTrashed();
    }
}
