mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-09-19 15:58:02 +00:00
33 lines
572 B
PHP
33 lines
572 B
PHP
<?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();
|
|
});
|
|
}
|
|
|
|
}
|