forked from mirror/pixelfed
Update Profile model
This commit is contained in:
parent
c7a4adb8ad
commit
1cba67b781
1 changed files with 9 additions and 27 deletions
|
@ -2,27 +2,16 @@
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
|
use Auth, Cache, Storage;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
use App\Util\Lexer\PrettyNumber;
|
||||||
use Auth;
|
use Illuminate\Database\Eloquent\{Model, SoftDeletes};
|
||||||
use Cache;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
use Storage;
|
|
||||||
|
|
||||||
class Profile extends Model
|
class Profile extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that should be mutated to dates.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
protected $hidden = [
|
protected $hidden = ['private_key'];
|
||||||
'private_key',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $visible = ['username', 'name'];
|
protected $visible = ['username', 'name'];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
@ -30,26 +19,19 @@ class Profile extends Model
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function url($suffix = '')
|
public function url($suffix = null)
|
||||||
{
|
{
|
||||||
if ($this->remote_url) {
|
return $this->remote_url ?? url($this->username . $suffix);
|
||||||
return $this->remote_url;
|
|
||||||
} else {
|
|
||||||
return url($this->username.$suffix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function localUrl($suffix = '')
|
public function localUrl($suffix = null)
|
||||||
{
|
{
|
||||||
return url($this->username.$suffix);
|
return url($this->username . $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function permalink($suffix = '')
|
public function permalink($suffix = null)
|
||||||
{
|
{
|
||||||
if($this->remote_url) {
|
return $this->remote_url ?? url('users/' . $this->username . $suffix);
|
||||||
return $this->remote_url;
|
|
||||||
}
|
|
||||||
return url('users/'.$this->username.$suffix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function emailUrl()
|
public function emailUrl()
|
||||||
|
|
Loading…
Reference in a new issue