| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * 会议-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
- class MeetingModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'meetings';
- protected $appends = ['areas','start_time','meeting_time','time_text','time_text1'];
- public function getThumbAttribute($value)
- {
- return $value? get_image_url($value) : '';
- }
- // 时间
- public function getTimeTextAttribute()
- {
- $startTime = $this->start_at? strtotime($this->start_at) : 0;
- $endTime = $this->end_at? strtotime($this->end_at) : time();
- $startAt = $this->start_at? datetime($this->start_at,'m月d日 H:i') : '';
- $formatType = 'm月d日 H:i';
- if($endTime && $endTime <= $startTime+86400){
- $formatType = 'H:i';
- }
- $endAt = date($formatType,$endTime);
- return $startAt.' - '.$endAt;
- }
- // 倒计时开始
- public function getStartTimeAttribute()
- {
- $dateTime = time();
- $time = $this->start_at? strtotime($this->start_at) : 0;
- return $time>$dateTime?intval($time-$dateTime) : 0;
- }
- // 会议时长
- public function getMeetingTimeAttribute()
- {
- $dateTime = time();
- $startTime = $this->start_at? strtotime($this->start_at) : 0;
- $endTime = $this->end_at? strtotime($this->end_at) : time();
- $startTime = $dateTime>$startTime?$dateTime:$startTime;
- return $endTime>$startTime?intval($endTime-$startTime) : 0;
- }
- // 时间
- public function getTimeText1Attribute()
- {
- $weeks = ['周日','周一','周二','周三','周四','周五','周六'];
- $startTime = $this->start_at? strtotime($this->start_at) : 0;
- $endTime = $this->end_at? strtotime($this->end_at) : time();
- $w = date('w',$startTime);
- $week = isset($weeks[$w])?' '.$weeks[$w].' ': '';
- $startAt = $this->start_at? datetime($this->start_at,"Y年m月d日").$week.datetime($this->start_at,"H:i") : '';
- $formatType = 'm月d日 H:i';
- if($endTime && $endTime <= $startTime+86400){
- $formatType = 'H:i';
- }
- $endAt = date($formatType,$endTime);
- return $startAt.' - '.$endAt;
- }
- /**
- * @return array
- */
- public function getAreasAttribute()
- {
- return [$this->province_id.'',$this->city_id.'',$this->district_id.''];
- }
- /**
- * @return array
- */
- public function getStoreIdsAttribute($value)
- {
- return $value? array_filter(explode(',', $value)):[];
- }
- /**
- * @return array
- */
- public function getSupervisorIdsAttribute($value)
- {
- return $value? array_filter(explode(',', $value)):[];
- }
- /**
- * 推荐组织人
- */
- public function member()
- {
- return $this->hasOne(MemberModel::class, 'id','user_id')
- ->where(['mark'=>1])
- ->select(['id', 'nickname','avatar', 'realname','position','company','department','is_auth', 'mobile', 'status']);
- }
- /**
- * 省份
- */
- public function province()
- {
- return $this->hasOne(CityModel::class, 'citycode','province_id')
- ->where(['mark'=>1]);
- }
- /**
- * 城市
- */
- public function city()
- {
- return $this->hasOne(CityModel::class, 'citycode','city_id')
- ->where(['mark'=>1]);
- }
- /**
- * 区县
- */
- public function district()
- {
- return $this->hasOne(CityModel::class, 'citycode','district_id')
- ->where(['mark'=>1]);
- }
- /**
- * 签到记录
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function records()
- {
- return $this->hasMany(MeetingRecordsModel::class, 'meeting_id','id')
- ->where(['mark'=>1]);
- }
- }
|