| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Module\Ulogic\Model;
- use App\Module\Ulogic\Enum\INTERNAL_TYPE;
- use App\Module\User\Services\User;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use UCore\ModelCore;
- /**
- * 站内信
- * field start
- * @property int $id
- * @property int $admin_id 管理员ID
- * @property int $from_id 来源用户ID
- * @property int $user_id
- * @property int $cate 分类
- * @property int $is_read 是否已读
- * @property string $status 状态
- * @property int $type1 类型
- * @property string $content 内容
- * @property int $template_id 模板ID
- * @property string $at_users at的用户
- * @property string $data 数据
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * @property \Carbon\Carbon $deleted_at 删除时间
- * field end
- *
- */
- class Internal extends ModelCore
- {
- use SoftDeletes;
- protected $casts = [
- 'type1' => INTERNAL_TYPE::class
- ];
- // attrlist start
- public static $attrlist = array (
- 0 => 'id',
- 1 => 'admin_id',
- 2 => 'from_id',
- 3 => 'user_id',
- 4 => 'cate',
- 5 => 'is_read',
- 6 => 'status',
- 7 => 'type1',
- 8 => 'content',
- 9 => 'template_id',
- 10 => 'at_users',
- 11 => 'data',
- 12 => 'created_at',
- 13 => 'updated_at',
- 14 => 'deleted_at',
- );
- //attrlist end
- protected $table = 'user_internals';
- protected $appends = [
- 'from_info'
- ];
- public function getFromInfoAttribute()
- {
- if ($this->from_id == 0) {
- return [
- 'nickname' => '管理员',
- 'avatar' => 1
- ];
- }
- $infos = User::pinfos([ $this->from_id ]);
- return $infos[$this->from_id] ?? [
- 'nickname' => '未知',
- 'user_id' => $this->from_id,
- 'avatar' => 0
- ];
- }
- }
|