diff --git a/backend/app/Data/UserDTO.php b/backend/app/Data/UserDTO.php index 4bcbeae..6a871c5 100644 --- a/backend/app/Data/UserDTO.php +++ b/backend/app/Data/UserDTO.php @@ -12,6 +12,7 @@ public function __construct( public string $email, public string $mobileNumber, public string $city, + public string $role ) {} /** @@ -25,6 +26,7 @@ public function toArray(): array 'email' => $this->email, 'mobileNumber' => $this->mobileNumber, 'city' => $this->city, + 'role' => $this->role, ]; } } diff --git a/backend/app/Enums/UserRoles.php b/backend/app/Enums/UserRoles.php new file mode 100644 index 0000000..561885e --- /dev/null +++ b/backend/app/Enums/UserRoles.php @@ -0,0 +1,10 @@ +name, email: $user->email, mobileNumber: $user->mobile_number, - city: $user->city + city: $user->city, + role: $user->role->value ); return response()->json($userDto->toArray()); diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php index 9fe693c..eb74b44 100644 --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; +use App\Enums\UserRoles; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -23,6 +24,7 @@ class User extends Authenticatable 'password', 'city', 'mobile_number', + 'role', ]; /** @@ -45,6 +47,7 @@ protected function casts(): array return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', + 'role' => UserRoles::class, ]; } } diff --git a/backend/database/migrations/2026_02_27_044159_add_role_to_users.php b/backend/database/migrations/2026_02_27_044159_add_role_to_users.php new file mode 100644 index 0000000..7158dc2 --- /dev/null +++ b/backend/database/migrations/2026_02_27_044159_add_role_to_users.php @@ -0,0 +1,23 @@ +enum('role', array_column(UserRoles::cases(), 'value'))->default(UserRoles::Customer->value); + }); + } + + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('role'); + }); + } +};