2018-11-19 04:53:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformer\Api;
|
|
|
|
|
2019-01-28 02:40:36 +00:00
|
|
|
use Auth;
|
2019-08-06 03:16:29 +00:00
|
|
|
use App\{
|
|
|
|
FollowRequest,
|
|
|
|
Profile
|
|
|
|
};
|
2018-11-19 04:53:05 +00:00
|
|
|
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;
|
2019-08-06 03:16:29 +00:00
|
|
|
$requested = false;
|
|
|
|
if($user) {
|
|
|
|
$requested = FollowRequest::whereFollowerId($user->id)
|
|
|
|
->whereFollowingId($profile->id)
|
|
|
|
->exists();
|
|
|
|
}
|
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,
|
2019-08-06 03:16:29 +00:00
|
|
|
'requested' => $requested,
|
2018-11-19 04:53:05 +00:00
|
|
|
'domain_blocking' => null,
|
|
|
|
'showing_reblogs' => null,
|
2019-01-28 02:40:36 +00:00
|
|
|
'endorsed' => false
|
2018-11-19 04:53:05 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|