pixelfed/app/Models/Portfolio.php

48 lines
1 KiB
PHP
Raw Normal View History

2022-10-17 07:59:23 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Services\AccountService;
class Portfolio extends Model
{
use HasFactory;
public $fillable = [
2023-01-21 14:48:27 +00:00
'profile_id',
2022-10-17 07:59:23 +00:00
'active',
'show_captions',
'show_license',
'show_location',
'show_timestamp',
'show_link',
'show_avatar',
'show_bio',
'profile_layout',
'profile_source'
];
protected $casts = [
'metadata' => 'json'
];
public function url($suffix = '')
2022-10-17 07:59:23 +00:00
{
$account = AccountService::get($this->profile_id);
if(!$account) {
return null;
}
return 'https://' . config('portfolio.domain') . config('portfolio.path') . '/' . $account['username'] . $suffix;
}
public function permalink($suffix = '')
{
$account = AccountService::get($this->profile_id);
return config('app.url') . '/account/portfolio/' . $account['username'] . $suffix;
2022-10-17 07:59:23 +00:00
}
}