2018-11-19 04:53:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformer\Api;
|
|
|
|
|
2019-01-28 02:40:36 +00:00
|
|
|
use Auth;
|
2018-11-19 04:53:05 +00:00
|
|
|
use App\Profile;
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
class RelationshipTransformer extends Fractal\TransformerAbstract
|
|
|
|
{
|
|
|
|
public function transform(Profile $profile)
|
|
|
|
{
|
2019-06-10 02:36:08 +00:00
|
|
|
$auth = Auth::check();
|
|
|
|
$user = $auth ? Auth::user()->profile : false;
|
2018-11-19 04:53:05 +00:00
|
|
|
return [
|
2019-01-28 02:40:36 +00:00
|
|
|
'id' => (string) $profile->id,
|
2019-06-10 02:36:08 +00:00
|
|
|
'following' => $auth ? $user->follows($profile) : false,
|
|
|
|
'followed_by' => $auth ? $user->followedBy($profile) : false,
|
|
|
|
'blocking' => $auth ? $user->blockedIds()->contains($profile->id) : false,
|
|
|
|
'muting' => $auth ? $user->mutedIds()->contains($profile->id) : false,
|
2018-11-19 04:53:05 +00:00
|
|
|
'muting_notifications' => null,
|
|
|
|
'requested' => null,
|
|
|
|
'domain_blocking' => null,
|
|
|
|
'showing_reblogs' => null,
|
2019-01-28 02:40:36 +00:00
|
|
|
'endorsed' => false
|
2018-11-19 04:53:05 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|