|
@@ -8,19 +8,15 @@ use League\Fractal;
|
|
use Cache;
|
|
use Cache;
|
|
use App\Services\HashidService;
|
|
use App\Services\HashidService;
|
|
use App\Services\LikeService;
|
|
use App\Services\LikeService;
|
|
|
|
+use App\Services\MediaService;
|
|
use App\Services\MediaTagService;
|
|
use App\Services\MediaTagService;
|
|
|
|
+use App\Services\StatusHashtagService;
|
|
use App\Services\StatusLabelService;
|
|
use App\Services\StatusLabelService;
|
|
use App\Services\ProfileService;
|
|
use App\Services\ProfileService;
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
class StatusTransformer extends Fractal\TransformerAbstract
|
|
class StatusTransformer extends Fractal\TransformerAbstract
|
|
{
|
|
{
|
|
- protected $defaultIncludes = [
|
|
|
|
- 'account',
|
|
|
|
- 'tags',
|
|
|
|
- 'media_attachments',
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
public function transform(Status $status)
|
|
public function transform(Status $status)
|
|
{
|
|
{
|
|
$taggedPeople = MediaTagService::get($status->id);
|
|
$taggedPeople = MediaTagService::get($status->id);
|
|
@@ -64,31 +60,10 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
|
'local' => (bool) $status->local,
|
|
'local' => (bool) $status->local,
|
|
'taggedPeople' => $taggedPeople,
|
|
'taggedPeople' => $taggedPeople,
|
|
'label' => StatusLabelService::get($status),
|
|
'label' => StatusLabelService::get($status),
|
|
- 'liked_by' => LikeService::likedBy($status)
|
|
|
|
|
|
+ 'liked_by' => LikeService::likedBy($status),
|
|
|
|
+ 'media_attachments' => MediaService::get($status->id),
|
|
|
|
+ 'account' => ProfileService::get($status->profile_id),
|
|
|
|
+ 'tags' => StatusHashtagService::statusTags($status->id)
|
|
];
|
|
];
|
|
}
|
|
}
|
|
-
|
|
|
|
- public function includeAccount(Status $status)
|
|
|
|
- {
|
|
|
|
- $account = $status->profile;
|
|
|
|
-
|
|
|
|
- return $this->item($account, new AccountTransformer());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function includeTags(Status $status)
|
|
|
|
- {
|
|
|
|
- $tags = $status->hashtags;
|
|
|
|
-
|
|
|
|
- return $this->collection($tags, new HashtagTransformer());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function includeMediaAttachments(Status $status)
|
|
|
|
- {
|
|
|
|
- return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(14), function() use($status) {
|
|
|
|
- if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
|
|
|
|
- $media = $status->media()->orderBy('order')->get();
|
|
|
|
- return $this->collection($media, new MediaTransformer());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
}
|
|
}
|