'array','comment_tag'=>'array']; public function getPicAttribute() { return isset($this->attributes['pic']) ? config('console.pic_path').$this->attributes['pic'] : NULL; } public function category(){ return $this->belongsTo(MentalityDrillCategory::class, 'category_id', 'id'); } public function extend(){ return $this->hasMany(MentalityDrillExtend::class, 'drill_id', 'id'); } public function subject(){ return $this->hasMany(MentalityDrillsSubject::class, 'mentality_drills_id', 'id'); } public function leaveMessage(){ return $this->hasMany(SpecialistInfoLeaveMessage::class, 'mentality_drills_id', 'id') ->with( ["user"=>function($with){ $with->select(['id','wx_nickname','wx_headimgurl','third_up_nickname','third_up_headimg']); } ] ); } protected static function booted() { static::creating(function ($model) { if (empty($model->two_category_id)){ $model->two_category_id = 0; } }); } }