我已经做了一个laravel项目发布新闻的功能,如果用户打开一个新新闻,那么我会将newid和userid添加到表中,这样我就知道是谁打开了它,现在我想以粗体显示我尝试的未读新闻有关系但我没有做到
我的模特新闻
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Auth;
class News extends Model
{
use SoftDeletes;
protected $fillable = [
'titles',
'content',
'user_id',
'filename',
'publish',
'category',
];
protected $dates = ['deleted_at'];
public function users() {
return $this->belongsTo('App\User','user_id');
}
public function readnew() {
return $this->hasMany('App\Readnews','user_id',Auth::user()->id);
}
}