1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 08:14:10 +00:00
pixelfed/app/Services/ProfileService.php

44 lines
690 B
PHP
Raw Normal View History

2019-02-14 21:23:33 +00:00
<?php
namespace App\Services;
2019-12-11 06:04:03 +00:00
use Cache;
use Illuminate\Support\Facades\Redis;
2019-02-14 21:23:33 +00:00
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;
});
}
}