| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Models\Mysql;
- use App\Models\Mongo\AgentAttrsLogsModel;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\DB;
- class ChannelModel extends BaseMysql
- {
- protected $table = 'channel';
- /**
- * UUID 键名
- * @var string
- */
- protected $uuidKeyName = 'uid';
- protected $appends = [];
- /**
- * The "booted" method of the model.
- *
- * @return void
- */
- protected static function boot()
- {
- parent::boot();
- self::creating(function ($model) {
- $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
- });
- self::created(function ($model) {
- $uuid = hashEncodeId($model->id);
- $model->{$model->uuidKeyName} = $uuid;
- $model->save();
- });
- }
- /**
- * 关联1个应用.
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function app()
- {
- return $this->hasOne(AppModel::class, 'uid', 'mom_app_uid');
- }
- /**
- * 关联一个代理
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function agent()
- {
- return $this->belongsTo(AgentModel::class, 'uid', 'agent_uid');
- }
- public function agentName()
- {
- return $this->belongsTo(AgentModel::class, 'agent_uid','uid');
- }
- /**
- * 关联渠道包
- */
- public function channelRow()
- {
- return $this->hasOne(PackModel::class,'channel_code','uid');
- }
- }
|