2 years ago

Read/Unread News

Posted 2 years ago by evripidesk

I have made a function to laravel project to post news, if a user open a new then I add to table the newid and userid so I will know who open it, now I want to display in bold the unread news I try with a relationship but I didnt manage to do it

my model News

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Auth;

class News extends Model
  use SoftDeletes;

  protected $fillable = [
  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);


Please sign in or create an account to participate in this conversation.