Recently I've started to learn laravel and currently I work with version 5.2. What I have is Flag/Report system with which user can Report item for various reasons and the report is saved in database. So far this works great. I want now in backend(admin dashboard) when I select report to see details of it to see also all users who are reported this particular item.
So far I see only one user but I can't figured how to make the model and query.
So my Item model has
public function report(){
return $this->belongsTo('App\Report');
}
Report mode has
public function reportedItem(){
return $this->hasMany('Item','item_id');
}
And in controller this
public function details( $report_id ){
$flags = Report::where('report_id', '=', $report_id)->get();
return view('details', compact('flags'));
}
In table reports
one item can have many reports from many users. Any help here is appreciated.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iPKffR
via IFTTT
Aucun commentaire:
Enregistrer un commentaire