37 lines
783 B
PHP
37 lines
783 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CrmRole extends Base
|
|
{
|
|
protected $fillable = [];
|
|
protected $guarded = [];
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne(User::class, 'id', 'user_id');
|
|
}
|
|
|
|
public function userLogs()
|
|
{
|
|
return $this->hasMany(CrmUserLog::class, 'role_id', 'id');
|
|
}
|
|
|
|
public function tagUserLogs()
|
|
{
|
|
return $this->hasMany(CrmUserLog::class, 'role_id', 'id')->whereNotNull('tagged_at');
|
|
}
|
|
|
|
public function comments()
|
|
{
|
|
return $this->hasMany(ClientComment::class, 'maker_user_id', 'user_id')->whereIn('type', ['crm', 'crm_t']);
|
|
}
|
|
|
|
public function wechat()
|
|
{
|
|
return $this->hasOne(Wechat::class, 'user_id', 'user_id');
|
|
}
|
|
}
|