Changes for mobile app

This commit is contained in:
Hillel Coren 2018-08-17 08:13:32 +03:00
parent 87ad60b71f
commit 76d3d09e7d
3 changed files with 17 additions and 1 deletions

View File

@ -467,6 +467,21 @@ class User extends Authenticatable
return true; return true;
} }
public function permissionsMap()
{
$data = [];
$permissions = json_decode($this->permissions);
if (! $permissions) {
return $data;
}
$keys = array_values((array) $permissions);
$values = array_fill(0, count($keys), true);
return array_combine($keys, $values);
}
} }
User::created(function ($user) User::created(function ($user)

View File

@ -146,6 +146,7 @@ class UserAccountTransformer extends EntityTransformer
return [ return [
'account_key' => $account->account_key, 'account_key' => $account->account_key,
'user_id' => (int) ($user->public_id + 1),
'name' => $account->present()->name ?: '', 'name' => $account->present()->name ?: '',
'token' => $account->getToken($user->id, $this->tokenName), 'token' => $account->getToken($user->id, $this->tokenName),
'default_url' => SITE_URL, 'default_url' => SITE_URL,

View File

@ -51,7 +51,7 @@ class UserTransformer extends EntityTransformer
'notify_paid' => (bool) $user->notify_paid, 'notify_paid' => (bool) $user->notify_paid,
'notify_approved' => (bool) $user->notify_approved, 'notify_approved' => (bool) $user->notify_approved,
'is_admin' => (bool) $user->is_admin, 'is_admin' => (bool) $user->is_admin,
'permissions' => (int) $user->getOriginal('permissions'), 'permissions' => $user->permissionsMap(),
]; ];
} }
} }