| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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 ActivityModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'activitys';
- protected $appends = ['time_text'];
- // 封面图
- public function getThumbAttribute($value)
- {
- $value = $value ? get_image_url($value) : '';
- return $value;
- }
- public function setThumbAttribute($value)
- {
- return $value ? get_image_path($value) : '';
- }
- // 时间
- public function getCreateTimeAttribute($value)
- {
- return $value ? datetime($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;
- }
- /**
- * 签到记录
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function signs()
- {
- return $this->hasMany(ActivitySignModel::class, 'activity_id','id')
- ->where(['mark'=>1]);
- }
- }
|