Add ProfileService

This commit is contained in:
Daniel Supernault 2019-02-14 14:23:33 -07:00
parent 705d4ef942
commit 896012bcaa
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -0,0 +1,43 @@
<?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;
});
}
}