<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Models;use Illuminate\Database\Eloquent\Model;class Channel extends Model{protected $fillable=['user_id','role_id','channel_name','channel_code','department_id','manager','reduce_type','redirect_status','ceiling_num','status','deal_at'];public function department(){return $this->belongsTo(Department::class,'department_id','id');}public function user(){return $this->hasOne(User::class,'id','user_id');}public function role(){return $this->hasOne(Role::class,'id','role_id');}public function ceilRecord(){return $this->hasMany(ChannelCeiling::class,'channel_code','channel_code');}public function page(){return $this->hasMany(DistributePage::class,'channel_code','channel_code');}public function dealRecord(){return $this->hasMany(DealRecord::class,'channel_code','channel_code');}public function scopeGetChannel($query,$id){return $query->select('id','channel_name','channel_code')->where(['department_id'=>$id,'status'=>1])->groupBy('channel_name')->get();}}
?>