第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

數(shù)據(jù)庫中的錯誤值

數(shù)據(jù)庫中的錯誤值

PHP
慕森卡 2022-01-14 15:15:01
我需要從reports記錄了 user_id 的表中獲取報告。我的模型<?phpnamespace App;use Illuminate\Database\Eloquent\Model;class Reports extends Model{    protected $table = 'reports';    // public $timestamps = false;    protected $fillable = [        'user_id', 'username', 'user_id_posted', 'username_posted', 'news_id','opinion_id','event_id','career_solution_id', 'subject', 'why_reporting','why_reporting_message','additional_message','private'    ];    public function career_solutionReport()    {        return $this->belongsTo('App\CareerSolution','career_solution_id','id');    }     public function eventReport()    {        return $this->belongsTo('App\Event','event_id','id');    }     public function newsReport()    {        return $this->belongsTo('App\News','news_id','id');    }     public function opinionReport()    {        return $this->belongsTo('App\Opinion','opinion_id','id');    }    public function user()    {        return $this->belongsTo('App\User','user_id','id');    }}我正在使用這條線:$reports = \App\Reports::where('user_id', Sentinel::getUser()->id)->get();但在 dd($reports);我得到了一些錯誤的值:所以,這里user_id應(yīng)該只有 548,這是我的 user_id。但我也收到來自user_id542 的報告,這是不正確的。
查看完整描述

1 回答

?
函數(shù)式編程

TA貢獻(xiàn)1807條經(jīng)驗 獲得超9個贊

我猜你的 Sentinel 模型中有你的關(guān)系設(shè)置:


public function reports()

{

    return $this->hasMany(Report::class, 'user_id', 'id');

}

然后你可以這樣做:


$reports = Sentinel::getUser()->reports;


查看完整回答
反對 回復(fù) 2022-01-14
  • 1 回答
  • 0 關(guān)注
  • 138 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號