mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Add HashtagService
This commit is contained in:
parent
9d9e9ce7fa
commit
a37971dd28
1 changed files with 32 additions and 0 deletions
32
app/Services/HashtagService.php
Normal file
32
app/Services/HashtagService.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Cache;
|
||||
use App\Hashtag;
|
||||
use App\StatusHashtag;
|
||||
|
||||
class HashtagService {
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Cache::remember('services:hashtag:by_id:' . $id, 3600, function() use($id) {
|
||||
$tag = Hashtag::find($id);
|
||||
if(!$tag) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'name' => $tag->name,
|
||||
'slug' => $tag->slug,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public static function count($id)
|
||||
{
|
||||
return Cache::remember('services:hashtag:count:by_id:' . $id, 3600, function() use($id) {
|
||||
return StatusHashtag::whereHashtagId($id)->count();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue