为了账号安全,请及时绑定邮箱和手机立即绑定

如何在职业解决方案表中从用户那里获取角色?

如何在职业解决方案表中从用户那里获取角色?

PHP
米脂 2021-10-15 15:39:15
我想角色(role_users从每用户表)career_solutionstable.I'm尝试添加一些图标供用户使用,但我只是做图标过滤一个大的疑难问题events,opinion以及news,但Career solution没有工作。对于events,opinion和news我用:$temp['role'] = $events->user->role;$temp['role'] = $opinion->user->role;$temp['role'] = $news->user->role;现在我正在尝试获得相同的值,$career_solution但$career_solution->user->role似乎不再起作用了......这是我的职业解决方案.php: <?phpnamespace App;use Illuminate\Database\Eloquent\Model;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;class CareerSolution extends Model{    protected $table = 'career_solutions';    public $timestamps = false;    protected $fillable = [        'user_id', 'subject','topic_category_id','topic_subcategory_id','quantity','expires_at','public','location','date','added','views','on_offer','optional','city','employment_type','estimated_salary','url','type','job_id','company','modified_date','city','indeedApply'    ];    public function user()    {        return $this->belongsTo('App\User','user_id','id');    }    public function country()    {        return $this->belongsTo('App\Country','location','id');    }    public function category()    {        return $this->belongsTo('App\Category','topic_category_id','id');    }    public function sub_category()    {        return $this->belongsTo('App\CareerSolutionCategory','topic_subcategory_id','id');    }}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 92 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信