Просмотр исходного кода

feat: adiciona criacao e edicao de usuario

ebagabee 1 месяц назад
Родитель
Сommit
ea3e116094

+ 1 - 0
app/Http/Requests/UserRequest.php

@@ -17,6 +17,7 @@ public function rules(): array
             'avatar'    => 'sometimes|nullable|image|max:2048',
             'avatar'    => 'sometimes|nullable|image|max:2048',
             'name'      => 'sometimes|string|nullable|max:255',
             'name'      => 'sometimes|string|nullable|max:255',
             'cpf'       => 'sometimes|nullable|string|max:14',
             'cpf'       => 'sometimes|nullable|string|max:14',
+            'phone'     => 'sometimes|nullable|string|max:20',
             'email'     => 'sometimes|email',
             'email'     => 'sometimes|email',
             'password'  => 'sometimes|string|nullable|min:8',
             'password'  => 'sometimes|string|nullable|min:8',
             'user_type' => ['sometimes', Rule::enum(UserTypeEnum::class)],
             'user_type' => ['sometimes', Rule::enum(UserTypeEnum::class)],

+ 1 - 0
app/Http/Resources/UserResource.php

@@ -16,6 +16,7 @@ public function toArray(Request $request): array
             'id'            => $this->id,
             'id'            => $this->id,
             'name'          => $this->name,
             'name'          => $this->name,
             'cpf'           => $this->cpf,
             'cpf'           => $this->cpf,
+            'phone'         => $this->phone,
             'email'         => $this->email,
             'email'         => $this->email,
             'language'      => $this->language,
             'language'      => $this->language,
             'user_type'       => $this->user_type,
             'user_type'       => $this->user_type,

+ 22 - 0
database/migrations/2026_05_07_000001_add_phone_to_users_table.php

@@ -0,0 +1,22 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->string('phone', 20)->nullable()->after('cpf');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->dropColumn('phone');
+        });
+    }
+};

+ 6 - 12
routes/authRoutes/user.php

@@ -10,21 +10,15 @@
 
 
     Route::get('/unit', 'indexByUnit');
     Route::get('/unit', 'indexByUnit');
 
 
-    Route::get('/', 'index')
-        ->middleware('permission:config.user,view');
+    Route::get('/', 'index');
 
 
-    Route::post('/', 'store')
-        ->middleware('permission:config.user,add');
+    Route::post('/', 'store');
 
 
-    Route::get('/{id}', 'show')
-        ->middleware('permission:config.user,view');
+    Route::get('/{id}', 'show');
 
 
-    Route::put('/{id}', 'update')
-        ->middleware('permission:config.user,edit');
+    Route::put('/{id}', 'update');
 
 
-    Route::delete('/{id}', 'destroy')
-        ->middleware('permission:config.user,delete');
+    Route::delete('/{id}', 'destroy');
 
 
-    Route::get('/all/types', 'getUserTypes')
-        ->middleware('permission:config.user,view');
+    Route::get('/all/types', 'getUserTypes');
 });
 });