123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\admin\model;
- use support\Model;
- class HomeBanner extends Model
- {
- const IS_DEL_YES = 1;
- const IS_DEL_NO = 0;
- /**
- * 居家banner
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'home_banner';
- public $timestamps = false;
- /**
- * Notes:获取顶部图
- * @param int $banner_category_id
- * @return array
- * User: YCP
- * Date: 2022/11/1
- */
- public static function getBannerInfo(int $banner_category_id)
- {
- return static::where(['banner_category_id' => $banner_category_id,'banner_is_del'=>0])
- ->get()->toArray();
- }
- /**
- * Notes:获取banner列表
- * @return array
- * User: YCP
- * Date: 2022/11/1
- */
- public static function getBannerList()
- {
- $list = static::select('*')
- ->where(['banner_is_del'=>static::IS_DEL_NO])
- ->get();
- $count = static::where(['banner_is_del'=>static::IS_DEL_NO])
- ->count();
- return [$list, $count];
- }
- //时间格式
- public function getBannerCreateTimeAttribute($value)
- {
- if($value == 0 || $value == ''){
- return 0;
- }else{
- return date('Y-m-d H:i:s', $value);
- }
- }
- //时间格式
- public function getBannerUpdateTimeAttribute($value)
- {
- if($value == 0 || $value == ''){
- return 0;
- }else{
- return date('Y-m-d H:i:s', $value);
- }
- }
- }
|