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');
}
public function readnew() {
return $this->hasMany('App\Readnews','user_id',Auth::user()->id);
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2CwVRQA
via IFTTT
Aucun commentaire:
Enregistrer un commentaire