123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\model;
- use think\Model;
- class TrainClass extends Model
- {
- public function getCoverAttr($value)
- {
- return 'https://'.config('app.ali_oss_bindurl').'/'.$value;
- }
- public function doneLog()
- {
- return $this->hasMany('TrainDoneLog','class_id');
- }
- public function TrainSumup()
- {
- return $this->hasMany('TrainSumup','class_id');
- }
- public function getQrcodeAttr($value)
- {
- if ($value) {
- return 'https://'.config('app.ali_oss_bindurl').'/'.$value;
- }
- }
- public function company()
- {
- return $this->belongsTo('Company','root_id','root_id')->bind(['company_name']);
- }
- public function lecturer(){
- return $this->hasOne(Lecturer::class, 'id','lecturer_id');
- }
- public function getIntroduceAttr($value)
- {
- $value = $value ?: '';
- return $value;
- }
- public function getImgsAttr($value)
- {
- $value = $value ? explode(',',$value) : [];
- $url = config('app.ali_oss_bindurl');
- foreach ($value as $key => $value) {
- $value[$key] = 'https://'.$url.'/'.$value;
- }
- return $value;
- }
- }
|