<?php

namespace App\Models\Traits;

use App\Models\User;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

trait BelongsToUser
{

    /**
     * Notes: 当前模型隶属用户
     * @Author: <C.Jason>
     * @Date  : 2019/9/6 10:37
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    //所属
    public function getUserNicknameAttribute()
    {
        return $this->user_id ? $this->user->info->nickname : '系统';
    }

}
