我想角色(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:
<?php
namespace 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');
}
}