Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrigindo bug de retorno das permissões do usuário #9

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}