93 lines
2.4 KiB
PHP
93 lines
2.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class CircleUser extends Model
|
||
|
|
{
|
||
|
|
public const DEFAULAVATAR = 'https://image.fulllinkai.com/202207/04/1fa9a906b956efa26852fb685a845fff.png?x-oss-process=style/scale1';
|
||
|
|
/**
|
||
|
|
* The attributes that are mass assignable.
|
||
|
|
*
|
||
|
|
* @var array<int, string>
|
||
|
|
*/
|
||
|
|
protected $fillable = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The attributes that should be hidden for serialization.
|
||
|
|
*
|
||
|
|
* @var array<int, string>
|
||
|
|
*/
|
||
|
|
protected $hidden = [];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'created_at' => 'datetime:Y-m-d H:i:s',
|
||
|
|
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function getMateConditionAttribute(){
|
||
|
|
if(is_string($this->attributes['mate_condition'])){
|
||
|
|
return $this->attributes['mate_condition'] = json_decode($this->attributes['mate_condition']);
|
||
|
|
}else{
|
||
|
|
return $this->attributes['mate_condition'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getAffectiveStateAttribute($affective_state){
|
||
|
|
switch ($affective_state){
|
||
|
|
case 1:
|
||
|
|
$value = '未婚';
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
$value = '离异无孩';
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
$value = '离异带孩';
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
$value = '离异不带孩';
|
||
|
|
break;
|
||
|
|
case 5:
|
||
|
|
$value = '丧偶';
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
$value = null;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
return $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setAffectiveStateAttribute($affective_state){
|
||
|
|
switch ($affective_state){
|
||
|
|
case '未婚':
|
||
|
|
$value = 1;
|
||
|
|
break;
|
||
|
|
case '离异无孩':
|
||
|
|
$value = 2;
|
||
|
|
break;
|
||
|
|
case '离异带孩':
|
||
|
|
$value = 3;
|
||
|
|
break;
|
||
|
|
case '离异不带孩':
|
||
|
|
$value = 4;
|
||
|
|
break;
|
||
|
|
case '丧偶':
|
||
|
|
$value = 5;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
$value = 0;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
$this->attributes['affective_state'] = $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function love_user(){
|
||
|
|
return $this->belongsTo(User::class,'love_user_id','id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function love_user_profile(){
|
||
|
|
return $this->belongsTo(ProfileCourtship::class,'love_user_id','user_id');
|
||
|
|
}
|
||
|
|
}
|