Files
x-server-mobile/backend/app/Model/CompanyFeishuApp.php
T

92 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace App\Model;
use support\Model;
class CompanyFeishuApp extends Model
{
protected $table = 'company_feishu_apps';
protected $fillable = [
'company_id',
'system_id',
'name',
'tenant_key',
'app_id',
'app_secret',
'encrypt_key',
'verification_token',
'base_uri',
'callback_url',
'mobile_callback_url',
'scopes',
'state',
'sort',
'status',
];
protected $casts = [
'company_id' => 'integer',
'system_id' => 'integer',
'sort' => 'integer',
'status' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected $hidden = [
'app_secret',
'encrypt_key',
'verification_token',
];
/**
* 关联公司
*/
public function company()
{
return $this->belongsTo(Company::class, 'company_id');
}
/**
* 获取启用的应用
*/
public function scopeActive($query)
{
return $query->where('status', 1);
}
/**
* 根据系统ID查找
*/
public function scopeBySystemId($query, int $systemId)
{
return $query->where('system_id', $systemId);
}
/**
* 获取X-Server应用
*/
public function scopeXServer($query)
{
return $query->where('system_id', 1);
}
/**
* 获取工单应用
*/
public function scopeTicket($query)
{
return $query->where('system_id', 2);
}
/**
* 获取CRM应用
*/
public function scopeCrm($query)
{
return $query->where('system_id', 3);
}
}