| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * 院校-模型
- * @author laravel开发员
- * @since 2024/01/08
- * @package App\Models
- */
- class InstitutionModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'institutions';
- /**
- * 格式化信息
- * @param array $info 实体数据对象
- * @return array 返回实体对象
- * @author laravel开发员
- * @date 2024/01/08
- */
- public function formatInfo($info)
- {
- // 格式化链接类型
- if (isset($info['link_type'])) {
- $linkTypeMap = [
- 1 => 'Web链接',
- 2 => '小程序链接'
- ];
- $info['link_type_text'] = isset($linkTypeMap[$info['link_type']]) ? $linkTypeMap[$info['link_type']] : '未知类型';
- }
- // 格式化状态
- if (isset($info['status'])) {
- $info['status_text'] = $info['status'] == 1 ? '正常' : '不显示';
- }
- return $info;
- }
- public function getThumbAttribute($value)
- {
- return $value ? get_image_url($value) : '';
- }
- public function setThumbAttribute($value)
- {
- $this->attributes['thumb'] = $value ? get_image_path($value) : '';
- }
- }
|