Portfolio.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Services\AccountService;
  6. class Portfolio extends Model
  7. {
  8. use HasFactory;
  9. public $fillable = [
  10. 'profile_id',
  11. 'active',
  12. 'show_captions',
  13. 'show_license',
  14. 'show_location',
  15. 'show_timestamp',
  16. 'show_link',
  17. 'show_avatar',
  18. 'show_bio',
  19. 'profile_layout',
  20. 'profile_source'
  21. ];
  22. protected $casts = [
  23. 'metadata' => 'json'
  24. ];
  25. public function url($suffix = '')
  26. {
  27. $account = AccountService::get($this->profile_id);
  28. if(!$account) {
  29. return null;
  30. }
  31. return 'https://' . config('portfolio.domain') . config('portfolio.path') . '/' . $account['username'] . $suffix;
  32. }
  33. public function permalink($suffix = '')
  34. {
  35. $account = AccountService::get($this->profile_id);
  36. return config('app.url') . '/account/portfolio/' . $account['username'] . $suffix;
  37. }
  38. }