mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 16:53:17 +00:00
43 lines
659 B
PHP
43 lines
659 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services;
|
||
|
|
||
|
use Cache, Redis;
|
||
|
|
||
|
use App\{
|
||
|
Follower,
|
||
|
Profile
|
||
|
};
|
||
|
|
||
|
class ProfileService {
|
||
|
|
||
|
protected $profile;
|
||
|
protected $profile_prefix;
|
||
|
|
||
|
public static function build()
|
||
|
{
|
||
|
return new self();
|
||
|
}
|
||
|
|
||
|
public function profile(Profile $profile)
|
||
|
{
|
||
|
$this->profile = $profile;
|
||
|
$this->profile_prefix = 'profile:model:'.$profile->id;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function profileId($id)
|
||
|
{
|
||
|
return Cache::rememberForever('profile:model:'.$id, function() use($id) {
|
||
|
return Profile::findOrFail($id);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public function get()
|
||
|
{
|
||
|
return Cache::rememberForever($this->profile_prefix, function() {
|
||
|
return $this->profile;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|