123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\model;
- use think\Model;
- class Building extends Model
- {
- public function getCoverAttr($value){
- if(empty($value)) return $value;
- $arr = explode(',', $value);
- $domain = config('app.ali_oss_bindurl');
- foreach($arr as &$item){
- $item = 'https://'.$domain.'/'.$item;
- }
- return $arr;
- }
- public function setCoverAttr($value){
- $domain = config('app.ali_oss_bindurl');
- $search = 'https://'.$domain.'/';
- return str_replace($search, '', $value);
- }
- public function getCoverShareImgAttr($value){
- if(empty($value)) return $value;
- $domain = config('app.ali_oss_bindurl');
- return 'https://'.$domain.'/'.$value;
- }
- public function setCoverShareImgAttr($value){
- $domain = config('app.ali_oss_bindurl');
- $search = 'https://'.$domain.'/';
- return str_replace($search, '', $value);
- }
- public function getNameAttr($value, $item){
- if ($item['community_id']) {
- $name = Community::where('id', $item['community_id'])->value('name');
- } else {
- $name = $value;
- }
- return $name;
- }
- public function getPinyinAttr($value, $item){
- if ($item['community_id']) {
- $name = Community::where('id', $item['community_id'])->field('name,initials')->find();
- if($name == null) return '';
- if ($name->initials) {
- $pinyin = $name->initials;
- }else{
- $name = $name->name;
- if (hanziInitials($name)) {
- $pinyin = strtoupper(hanziInitials($name));
- } else {
- $pinyin = strtoupper(mb_substr($name,0,1));
- }
- }
- } else {
- $pinyin = $value;
- }
- return $pinyin;
- }
- public function progress(){
- return $this->hasMany(BuildingProgress::class, 'building_id', 'id');
- }
- public function housetype(){
- return $this->hasMany(BuildingHousetype::class, 'building_id', 'id');
- }
- public function materialCase(){
- return $this->hasMany(BuildingMaterialCase::class, 'building_id', 'id');
- }
- public function shareLog(){
- return $this->hasMany(ShareLog::class, 'data_id','id');
- }
- public function employee(){
- return $this->hasOne(Employee::class, 'id','employee_id');//->bind(['employee_name'=> 'opt_name']);
- }
- public function devcase(){
- return $this->hasMany(BuildingDevelopCase::class, 'building_id','id');
- }
- public function construction(){
- return $this->hasMany(BuildingConstruction::class, 'building_id','id');
- }
- }
|