mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update Profile model
This commit is contained in:
parent
18b712e790
commit
e395a9b0f6
1 changed files with 31 additions and 2 deletions
|
@ -3,12 +3,30 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Storage;
|
||||
|
||||
class Profile extends Model
|
||||
{
|
||||
public function url()
|
||||
protected $hidden = [
|
||||
'private_key',
|
||||
];
|
||||
|
||||
protected $visible = ['id', 'username', 'name'];
|
||||
|
||||
public function url($suffix = '')
|
||||
{
|
||||
return url('/' . $this->username);
|
||||
return url('/@' . $this->username . $suffix);
|
||||
}
|
||||
|
||||
public function permalink($suffix = '')
|
||||
{
|
||||
return url('users/' . $this->username . $suffix);
|
||||
}
|
||||
|
||||
public function emailUrl()
|
||||
{
|
||||
$domain = parse_url(config('app.url'), PHP_URL_HOST);
|
||||
return $this->username . '@' . $domain;
|
||||
}
|
||||
|
||||
public function statuses()
|
||||
|
@ -44,4 +62,15 @@ class Profile extends Model
|
|||
{
|
||||
return $this->hasMany(Like::class);
|
||||
}
|
||||
|
||||
public function avatar()
|
||||
{
|
||||
return $this->hasOne(Avatar::class);
|
||||
}
|
||||
|
||||
public function avatarUrl()
|
||||
{
|
||||
$url = url(Storage::url($this->avatar->media_path ?? 'public/avatars/default.png'));
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue