Read/Unread News

Posted 10 months 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 = [
    'titles',
    'content',
    'user_id',
    'filename',
    'publish',
    'category',
  ];
  protected $dates = ['deleted_at'];

  public function users() {
      return $this->belongsTo('App\User','user_id');

  }
//Auth::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.