mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 00:05:29 +00:00
Update Story model
This commit is contained in:
parent
2593cdeed9
commit
e1a3e26644
1 changed files with 42 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Storage;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Pixelfed\Snowflake\HasSnowflakePrimary;
|
use Pixelfed\Snowflake\HasSnowflakePrimary;
|
||||||
|
|
||||||
|
@ -19,14 +20,11 @@ class Story extends Model
|
||||||
*/
|
*/
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
/**
|
protected $casts = [
|
||||||
* The attributes that should be mutated to dates.
|
'expires_at' => 'immutable_datetime'
|
||||||
*
|
];
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dates = ['published_at', 'expires_at'];
|
|
||||||
|
|
||||||
protected $fillable = ['profile_id'];
|
protected $fillable = ['profile_id', 'view_count'];
|
||||||
|
|
||||||
protected $visible = ['id'];
|
protected $visible = ['id'];
|
||||||
|
|
||||||
|
@ -51,6 +49,42 @@ class Story extends Model
|
||||||
|
|
||||||
public function permalink()
|
public function permalink()
|
||||||
{
|
{
|
||||||
return url("/story/$this->id");
|
$username = $this->profile->username;
|
||||||
|
return url("/stories/{$username}/{$this->id}/activity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function url()
|
||||||
|
{
|
||||||
|
$username = $this->profile->username;
|
||||||
|
return url("/stories/{$username}/{$this->id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mediaUrl()
|
||||||
|
{
|
||||||
|
return url(Storage::url($this->path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bearcapUrl()
|
||||||
|
{
|
||||||
|
return "bear:?t={$this->bearcap_token}&u={$this->url()}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeToAudience($scope)
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
|
||||||
|
switch ($scope) {
|
||||||
|
case 'to':
|
||||||
|
$res = [
|
||||||
|
$this->profile->permalink('/followers')
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$res = [];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue