Explorar o código

Update Story Model

Daniel Supernault %!s(int64=6) %!d(string=hai) anos
pai
achega
353b8fd856
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      app/Story.php

+ 8 - 1
app/Story.php

@@ -2,12 +2,13 @@
 
 namespace App;
 
+use Auth;
 use Illuminate\Database\Eloquent\Model;
 
 class Story extends Model
 {
 	protected $visible = ['id'];
-	
+
 	public function profile()
 	{
 		return $this->belongsTo(Profile::class);
@@ -27,4 +28,10 @@ class Story extends Model
 	{
 		return $this->hasMany(StoryView::class);
 	}
+
+	public function seen($pid = false)
+	{
+		$id = $pid ?? Auth::user()->profile->id;
+		return $this->views()->whereProfileId($id)->exists();
+	}
 }