2018-11-04 03:45:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
2019-01-12 20:14:22 +00:00
|
|
|
use Auth;
|
2018-11-04 03:45:44 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Story extends Model
|
|
|
|
{
|
2019-01-12 19:38:09 +00:00
|
|
|
protected $visible = ['id'];
|
2019-01-12 20:14:22 +00:00
|
|
|
|
2019-01-12 19:38:09 +00:00
|
|
|
public function profile()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Profile::class);
|
|
|
|
}
|
|
|
|
|
2019-01-12 07:42:26 +00:00
|
|
|
public function items()
|
|
|
|
{
|
|
|
|
return $this->hasMany(StoryItem::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function reactions()
|
|
|
|
{
|
|
|
|
return $this->hasMany(StoryReaction::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function views()
|
|
|
|
{
|
|
|
|
return $this->hasMany(StoryView::class);
|
|
|
|
}
|
2019-01-12 20:14:22 +00:00
|
|
|
|
|
|
|
public function seen($pid = false)
|
|
|
|
{
|
|
|
|
$id = $pid ?? Auth::user()->profile->id;
|
|
|
|
return $this->views()->whereProfileId($id)->exists();
|
|
|
|
}
|
2018-11-04 03:45:44 +00:00
|
|
|
}
|