1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-22 15:55:14 +00:00
pixelfed/app/Status.php

46 lines
841 B
PHP
Raw Normal View History

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
2018-04-17 01:24:18 +00:00
use Storage;
use Vinkla\Hashids\Facades\Hashids;
class Status extends Model
{
2018-04-17 01:24:18 +00:00
public function profile()
{
return $this->belongsTo(Profile::class);
}
public function media()
{
return $this->hasMany(Media::class);
}
public function firstMedia()
{
return $this->hasMany(Media::class)->orderBy('order', 'asc')->first();
}
public function url()
{
$hid = Hashids::encode($this->id);
$username = $this->profile->username;
return url("/p/@{$username}/{$hid}");
}
public function mediaUrl()
{
$path = $this->firstMedia()->media_path;
$url = Storage::url($path);
return url($url);
}
public function likes()
{
return $this->hasMany(Like::class);
}
}