55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
|
|
use app\util\Util;
|
|
use config\constants\Constants;
|
|
use DateTimeInterface;
|
|
use Illuminate\Support\Carbon;
|
|
use support\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Tag extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'crm_tag';
|
|
|
|
/**
|
|
* The primary key associated with the table.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = 'id';
|
|
|
|
//设置黑名单
|
|
protected $guarded = ['id','created_at','updated_at'];
|
|
|
|
// 指定日期字段存储格式为时间戳
|
|
protected $dateFormat = 'U';
|
|
|
|
/**
|
|
* Indicates if the model should be timestamped.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public $timestamps = true;
|
|
|
|
use SoftDeletes;
|
|
protected $dates = ['deleted_at'];
|
|
|
|
// 定义反向多对一关联
|
|
public function group()
|
|
{
|
|
return $this->belongsTo(TagGroup::class, 'group_id', 'id');
|
|
}
|
|
|
|
public function customers()
|
|
{
|
|
return $this->belongsToMany(Customer::class, 'customer_tag', 'tag_id', 'customer_id');
|
|
}
|
|
} |