1
0
Fork 0
pixelfed/app/Story.php

48 lines
830 B
PHP
Raw Normal View History

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;
2019-11-11 00:25:28 +00:00
use Pixelfed\Snowflake\HasSnowflakePrimary;
2018-11-04 03:45:44 +00:00
class Story extends Model
{
2019-11-11 00:25:28 +00:00
use HasSnowflakePrimary;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['published_at', 'expires_at'];
2019-12-31 09:33:54 +00:00
protected $fillable = ['profile_id'];
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 views()
{
return $this->hasMany(StoryView::class);
}
2019-01-12 20:14:22 +00:00
public function seen($pid = false)
{
2019-12-31 09:33:54 +00:00
return StoryView::whereStoryId($this->id)
->whereProfileId(Auth::user()->profile->id)
->exists();
2019-01-12 20:14:22 +00:00
}
2018-11-04 03:45:44 +00:00
}