Skip to content

Commit

Permalink
Merge pull request #9 from Guilherme-Silva0/alterando-apresentacao-da…
Browse files Browse the repository at this point in the history
…s-permissoes-do-usuario

Corrigindo bug de retorno das permissões do usuário
  • Loading branch information
Guilherme-Silva0 authored Jul 2, 2024
2 parents e73ee8f + 8794efb commit 0193003
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(

public function index()
{
return User::select(
$user = User::select(
'uuid',
'name',
'cidade',
Expand All @@ -46,6 +46,8 @@ public function index()
'created_at',
'updated_at'
)->get();

return $this->response->json($user);
}

public function create(UserRegisterRequest $request)
Expand Down
37 changes: 26 additions & 11 deletions app/Model/User.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/

namespace App\Model;

use Carbon\Carbon;
use Hyperf\DbConnection\Model\Model;

/**
* @property int $id
* @property string $uuid
* @property string $name
* @property string $email
* @property string $birth_date
* @property string $document
* @property string $cellphone
* @property string $password
* @property string $remember_token
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $id
* @property string $uuid
* @property string $name
* @property string $email
* @property string $birth_date
* @property string $document
* @property string $cellphone
* @property string $password
* @property string $remember_token
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class User extends Model
{
Expand All @@ -34,10 +43,16 @@ class User extends Model
protected array $guarded = [];

protected array $hidden = ['password', 'email', 'id', 'remember_token'];

/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

/* protected ?string $connection = 'default'; */

public function getPermissionsAttribute($value)
{
return unserialize($value);
}
}

0 comments on commit 0193003

Please sign in to comment.