From 0c59cd7a3627049a4984e42ca28573f00b800239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Mon, 10 Jun 2024 14:49:33 -0300 Subject: [PATCH 1/6] ajustando gut e 5w2h --- app/Http/Controllers/EmpresaController.php | 10 +++---- app/Models/Gut.php | 6 ++-- app/Models/T5w2h.php | 21 ++++++++++---- app/Models/Tarefa.php | 18 ++++++++++++ database/factories/GutFactory.php | 2 -- database/factories/T5w2hFactory.php | 3 +- database/factories/TarefaFactory.php | 23 +++++++++++++++ .../2024_05_12_150326_create_guts_table.php | 1 - ...2024_06_09_175036_create_tarefas_table.php | 28 +++++++++++++++++++ ...2024_06_10_140640_create_t5w2hs_table.php} | 3 +- ..._06_10_141435_create_subtarefas_table.php} | 0 database/seeders/DatabaseSeeder.php | 15 ++++++---- routes/api.php | 9 ++++-- 13 files changed, 111 insertions(+), 28 deletions(-) create mode 100644 app/Models/Tarefa.php create mode 100644 database/factories/TarefaFactory.php create mode 100644 database/migrations/2024_06_09_175036_create_tarefas_table.php rename database/migrations/{2024_05_12_122318_create_t5w2hs_table.php => 2024_06_10_140640_create_t5w2hs_table.php} (83%) rename database/migrations/{2024_05_12_144822_create_subtarefas_table.php => 2024_06_10_141435_create_subtarefas_table.php} (100%) diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index 91ac21e..f737ca0 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -38,13 +38,14 @@ function partnerCompanies(Usuario $hash) /** * Retorna todos os registros da tabela 'empresas' que tem Usuario recebido como parceiro. * Devolve um erro 404 ao cliente se o usuario não for encontrado. - * + * * @param \App\Models\Usuario $hash parceiro das empresas. */ return $hash->empresasParceiras; } - function storeT5w2h(Request $request,Empresa $empresa, Usuario $hash) { + function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) + { $t5w2h = $empresa->t5w2hs; $contents = $request->all(); @@ -52,7 +53,7 @@ function storeT5w2h(Request $request,Empresa $empresa, Usuario $hash) { $validator = Validator::make($contents, [ "*.pergunta_id" => "required", "*.resposta" => "required", - "*.tarefa" => "nullable" + "*.tarefa_id" => "required|int" ]); if ($validator->fails()) { @@ -60,10 +61,9 @@ function storeT5w2h(Request $request,Empresa $empresa, Usuario $hash) { } foreach ($contents as $content) { - T5w2h::updateOrCreate(["empresa_id" => $empresa->id,"pergunta_id" => $content["pergunta_id"]], ["resposta" => $content['resposta'], "tarefa" => $content["tarefa"]]); + T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $content["pergunta_id"]], ["resposta" => $content['resposta'], "tarefa_id" => $content["tarefa_id"]]); } return response()->json(['success' => 'Registros feitos com sucesso'], 201); - } function companieTasks(Empresa $empresa, string $hash) diff --git a/app/Models/Gut.php b/app/Models/Gut.php index d0ab2fa..f3ef0fa 100644 --- a/app/Models/Gut.php +++ b/app/Models/Gut.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class Gut extends Model { @@ -16,7 +17,8 @@ class Gut extends Model 'tendencia' ]; - function t5w2h() : BelongsTo { - return $this->belongsTo(T5w2h::class, '5w2h_id')->withDefault(); + function t5w2hs(): HasMany + { + return $this->hasMany(T5w2h::class)->withDefault(); } } diff --git a/app/Models/T5w2h.php b/app/Models/T5w2h.php index dd296f1..0c362a1 100644 --- a/app/Models/T5w2h.php +++ b/app/Models/T5w2h.php @@ -15,22 +15,31 @@ class T5w2h extends Model protected $fillable = [ "pergunta_id", "resposta", - "tarefa" + //"tarefa" ]; - function pergunta() : BelongsTo { + function pergunta(): BelongsTo + { return $this->belongsTo(Pergunta::class)->withDefault(); } - function empresa() : BelongsTo { + function empresa(): BelongsTo + { return $this->belongsTo(Empresa::class)->withDefault(); } - function subtarefas() : HasMany { + function subtarefas(): HasMany + { return $this->hasMany(Subtarefa::class, '5w2h_id'); } - function gut() : HasOne { - return $this->hasOne(T5w2h::class, '5w2h_id'); + function gut(): BelongsTo + { + return $this->belongsTo(Gut::class); + } + + function tarefa(): BelongsTo + { + return $this->belongsTo(Tarefa::class); } } diff --git a/app/Models/Tarefa.php b/app/Models/Tarefa.php new file mode 100644 index 0000000..063c8f2 --- /dev/null +++ b/app/Models/Tarefa.php @@ -0,0 +1,18 @@ +hasMany(T5w2h::class); + } +} diff --git a/database/factories/GutFactory.php b/database/factories/GutFactory.php index f91feb4..f332175 100644 --- a/database/factories/GutFactory.php +++ b/database/factories/GutFactory.php @@ -2,7 +2,6 @@ namespace Database\Factories; -use App\Models\T5w2h; use Illuminate\Database\Eloquent\Factories\Factory; /** @@ -18,7 +17,6 @@ class GutFactory extends Factory public function definition(): array { return [ - '5w2h_id' => T5w2h::all()->random()->id, 'gravidade' => fake()->numberBetween(1, 5), 'urgencia' => fake()->numberBetween(1, 5), 'tendencia' => fake()->numberBetween(1, 5), diff --git a/database/factories/T5w2hFactory.php b/database/factories/T5w2hFactory.php index 03a6943..c7ebaad 100644 --- a/database/factories/T5w2hFactory.php +++ b/database/factories/T5w2hFactory.php @@ -19,9 +19,8 @@ class T5w2hFactory extends Factory public function definition(): array { return [ - 'empresa_id' => Empresa::all()->random()->id, + //'empresa_id' => Empresa::all()->random()->id, 'resposta' => fake()->sentence(), - 'tarefa' => fake()->sentence() ]; } } diff --git a/database/factories/TarefaFactory.php b/database/factories/TarefaFactory.php new file mode 100644 index 0000000..2c40310 --- /dev/null +++ b/database/factories/TarefaFactory.php @@ -0,0 +1,23 @@ + + */ +class TarefaFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'descrição' => fake()->sentence() + ]; + } +} diff --git a/database/migrations/2024_05_12_150326_create_guts_table.php b/database/migrations/2024_05_12_150326_create_guts_table.php index ebfcd0d..2081202 100644 --- a/database/migrations/2024_05_12_150326_create_guts_table.php +++ b/database/migrations/2024_05_12_150326_create_guts_table.php @@ -13,7 +13,6 @@ public function up(): void { Schema::create('guts', function (Blueprint $table) { $table->id(); - $table->foreignId('5w2h_id')->references('id')->on('t5w2hs'); $table->integer('gravidade'); $table->integer('urgencia'); $table->integer('tendencia'); diff --git a/database/migrations/2024_06_09_175036_create_tarefas_table.php b/database/migrations/2024_06_09_175036_create_tarefas_table.php new file mode 100644 index 0000000..8768193 --- /dev/null +++ b/database/migrations/2024_06_09_175036_create_tarefas_table.php @@ -0,0 +1,28 @@ +id(); + $table->string("descrição"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tarefas'); + } +}; diff --git a/database/migrations/2024_05_12_122318_create_t5w2hs_table.php b/database/migrations/2024_06_10_140640_create_t5w2hs_table.php similarity index 83% rename from database/migrations/2024_05_12_122318_create_t5w2hs_table.php rename to database/migrations/2024_06_10_140640_create_t5w2hs_table.php index 42053e5..7a130ae 100644 --- a/database/migrations/2024_05_12_122318_create_t5w2hs_table.php +++ b/database/migrations/2024_06_10_140640_create_t5w2hs_table.php @@ -15,8 +15,9 @@ public function up(): void $table->id(); $table->foreignId('empresa_id')->references('id')->on('empresas'); $table->foreignId('pergunta_id')->references('id')->on('perguntas'); + $table->foreignId('gut_id')->references('id')->on('guts'); + $table->foreignId('tarefa_id')->references('id')->on('tarefas'); $table->string('resposta'); - $table->string('tarefa')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2024_05_12_144822_create_subtarefas_table.php b/database/migrations/2024_06_10_141435_create_subtarefas_table.php similarity index 100% rename from database/migrations/2024_05_12_144822_create_subtarefas_table.php rename to database/migrations/2024_06_10_141435_create_subtarefas_table.php diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 486664e..df8d563 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -7,6 +7,7 @@ use App\Models\Pergunta; use App\Models\Subtarefa; use App\Models\T5w2h; +use App\Models\Tarefa; use App\Models\Usuario; use Illuminate\Database\Eloquent\Factories\Sequence; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; @@ -44,15 +45,17 @@ public function run(): void // Cria 7 registros na tabela 5w2h para cada empressa representando as 7 perguntas $empresas->each(function (Empresa $emp) { - $emp->t5w2hs()->saveMany( - T5w2h::factory(7)->sequence( - fn (Sequence $sequence) => ['pergunta_id' => $sequence->index + 1] - )->create() - ); + $gut = Gut::factory()->create(); + $tarefa = Tarefa::factory()->create(); + $t5w2hs = T5w2h::factory(7)->sequence( + fn (Sequence $sequence) => ['pergunta_id' => $sequence->index + 1] + )->for($gut)->for($tarefa)->for($emp)->create(); + //Tarefa::factory()->has($t5w2hs)->create(); + //$emp->t5w2hs()->saveMany($t5w2hs); }); Subtarefa::factory(5)->create(); - Gut::factory(5)->create(); + //Gut::factory(5)->create(); } } diff --git a/routes/api.php b/routes/api.php index b341489..6d62063 100644 --- a/routes/api.php +++ b/routes/api.php @@ -19,7 +19,7 @@ */ -Route::controller(UsuarioController::class)->prefix('users/')->group( function () { +Route::controller(UsuarioController::class)->prefix('users/')->group(function () { // Define um grupo de rotas para o recurso 'Usuario' // Todas as rotas aqui têm o prefixo 'users/' adicionado a URI antes de serem processadas // As rotas autocamticamente chamam metodos na UsuarioController @@ -55,19 +55,21 @@ Route::get('', 'index'); // Define uma rota GET para listar todas as empresas de um usuario - Route::get('user/', 'userCompanies'); + Route::get('user/{hash}', 'userCompanies'); // Define um rota POST para fazer registros nas tabela 5w2h da empresa Route::post('t5w2h/{empresa}/{hash}', 'storeT5w2h'); // Define uma rota GET para retornar lista de empresas a partir da id do usuário parceiro - Route::get('partner/', 'partnerCompanies'); + Route::get('partner/{hash}', 'partnerCompanies'); // Define uma rota GET para exibir uma empresa específica Route::get('{empresa}/', 'show'); // Define uma rota GET para listar todas as tarefas e subtarefas a partir de uma empresa Route::get('{empresa}/tarefas/', 'companieTasks'); + // Define um rota POST para fazer registros de tarefas para 5w2h + Route::post('{empresa}/tarefas/{hash}', 'storeTasks'); // Define uma rota POST para criar uma nova empresa Route::post('{hash}', 'store'); @@ -89,6 +91,7 @@ }); + // IA // Route::get('/gemini', [GeminiController::class, 'index']); From 74b1623a493ab51ac74b97587983a1c563c19028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Mon, 10 Jun 2024 21:13:17 -0300 Subject: [PATCH 2/6] Finalizando ajustes na 5w2h --- app/Http/Controllers/EmpresaController.php | 27 +++++++++++++++---- app/Models/T5w2h.php | 2 ++ app/Models/Tarefa.php | 4 ++- .../2024_06_10_140640_create_t5w2hs_table.php | 4 +-- routes/api.php | 5 ++-- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index f737ca0..754d245 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Tarefa; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; @@ -51,17 +52,19 @@ function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) $contents = $request->all(); $validator = Validator::make($contents, [ - "*.pergunta_id" => "required", - "*.resposta" => "required", - "*.tarefa_id" => "required|int" + "tarefa" => "required|string", + "respostas.*.pergunta_id" => "required|int", + "respostas.*.resposta" => "required|string", ]); + if ($validator->fails()) { return response()->json(['errors' => $validator->errors()], 422); } + $tarefa = Tarefa::firstOrCreate(["descrição"=> $contents["tarefa"]]); - foreach ($contents as $content) { - T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $content["pergunta_id"]], ["resposta" => $content['resposta'], "tarefa_id" => $content["tarefa_id"]]); + foreach ($contents["respostas"] as $resposta) { + T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $resposta["pergunta_id"], "tarefa_id" => $tarefa->id], ["resposta" => $resposta['resposta']]); } return response()->json(['success' => 'Registros feitos com sucesso'], 201); } @@ -202,4 +205,18 @@ public function destroy(string $empresaId, string $userHash) } return response()->json(['errors' => 'Erro ao deletar empresa'], 400); } + + public function showT5w2h(Empresa $empresa, Usuario $usuario) + { + return $empresa->t5w2hs()->with( + 'tarefa:id,descrição', 'pergunta:id,pergunta', 'gut:id,gravidade,urgencia,tendencia' + )->get([ + 'id', + 'empresa_id', + 'tarefa_id', + 'pergunta_id', + 'gut_id', + 'resposta' + ]); + } } diff --git a/app/Models/T5w2h.php b/app/Models/T5w2h.php index 0c362a1..16aa212 100644 --- a/app/Models/T5w2h.php +++ b/app/Models/T5w2h.php @@ -14,7 +14,9 @@ class T5w2h extends Model protected $fillable = [ "pergunta_id", + "tarefa_id", "resposta", + "empresa_id" //"tarefa" ]; diff --git a/app/Models/Tarefa.php b/app/Models/Tarefa.php index 063c8f2..afe9f0d 100644 --- a/app/Models/Tarefa.php +++ b/app/Models/Tarefa.php @@ -10,7 +10,9 @@ class Tarefa extends Model { use HasFactory; - + protected $fillable = [ + "descrição", + ]; public function t5w2hs(): HasMany { return $this->hasMany(T5w2h::class); diff --git a/database/migrations/2024_06_10_140640_create_t5w2hs_table.php b/database/migrations/2024_06_10_140640_create_t5w2hs_table.php index 7a130ae..10a81cc 100644 --- a/database/migrations/2024_06_10_140640_create_t5w2hs_table.php +++ b/database/migrations/2024_06_10_140640_create_t5w2hs_table.php @@ -14,9 +14,9 @@ public function up(): void Schema::create('t5w2hs', function (Blueprint $table) { $table->id(); $table->foreignId('empresa_id')->references('id')->on('empresas'); - $table->foreignId('pergunta_id')->references('id')->on('perguntas'); - $table->foreignId('gut_id')->references('id')->on('guts'); $table->foreignId('tarefa_id')->references('id')->on('tarefas'); + $table->foreignId('pergunta_id')->references('id')->on('perguntas'); + $table->foreignId('gut_id')->nullable()->references('id')->on('guts'); $table->string('resposta'); $table->timestamps(); }); diff --git a/routes/api.php b/routes/api.php index 6d62063..eec98de 100644 --- a/routes/api.php +++ b/routes/api.php @@ -57,6 +57,9 @@ // Define uma rota GET para listar todas as empresas de um usuario Route::get('user/{hash}', 'userCompanies'); + // Define uma rota GET para listar registros da 5w2h + Route::get('t5w2h/{empresa}/{hash}', 'showT5w2h'); + // Define um rota POST para fazer registros nas tabela 5w2h da empresa Route::post('t5w2h/{empresa}/{hash}', 'storeT5w2h'); @@ -68,8 +71,6 @@ // Define uma rota GET para listar todas as tarefas e subtarefas a partir de uma empresa Route::get('{empresa}/tarefas/', 'companieTasks'); - // Define um rota POST para fazer registros de tarefas para 5w2h - Route::post('{empresa}/tarefas/{hash}', 'storeTasks'); // Define uma rota POST para criar uma nova empresa Route::post('{hash}', 'store'); From 7172dcba7d6d7a9328826e532217b3f8258cb187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Tue, 11 Jun 2024 00:57:30 -0300 Subject: [PATCH 3/6] =?UTF-8?q?criando=20fun=C3=A7=C3=A3o=20de=20sugerir?= =?UTF-8?q?=20gut=20e=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmpresaController.php | 13 ++++++-- app/Http/Controllers/GeminiController.php | 36 +++++++++++++++++++++- routes/api.php | 12 +++++--- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index 754d245..b2b8f55 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Gut; use App\Models\Tarefa; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -48,11 +49,14 @@ function partnerCompanies(Usuario $hash) function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) { - $t5w2h = $empresa->t5w2hs; + $contents = $request->all(); $validator = Validator::make($contents, [ "tarefa" => "required|string", + "gut.gravidade"=> "required", + "gut.urgencia"=> "required", + "gut.tendencia"=> "required", "respostas.*.pergunta_id" => "required|int", "respostas.*.resposta" => "required|string", ]); @@ -62,14 +66,17 @@ function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) return response()->json(['errors' => $validator->errors()], 422); } $tarefa = Tarefa::firstOrCreate(["descrição"=> $contents["tarefa"]]); + $gut = Gut::firstOrCreate($request['gut']); foreach ($contents["respostas"] as $resposta) { - T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $resposta["pergunta_id"], "tarefa_id" => $tarefa->id], ["resposta" => $resposta['resposta']]); + $t5w2h = T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $resposta["pergunta_id"], "tarefa_id" => $tarefa->id], ["resposta" => $resposta['resposta']]); + $t5w2h->gut()->associate($gut); + $t5w2h->save(); } return response()->json(['success' => 'Registros feitos com sucesso'], 201); } - function companieTasks(Empresa $empresa, string $hash) + function companieTasks(Empresa $empresa, Usuario $hash) { //retornar tarefas e subtarefas da empresa recebida como parametro. diff --git a/app/Http/Controllers/GeminiController.php b/app/Http/Controllers/GeminiController.php index 4a3f412..213b41f 100644 --- a/app/Http/Controllers/GeminiController.php +++ b/app/Http/Controllers/GeminiController.php @@ -8,6 +8,7 @@ use Gemini\Enums\Role; use Gemini\Laravel\Facades\Gemini; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; class GeminiController extends Controller { @@ -19,6 +20,15 @@ public function index() public function tasks(Request $request, Usuario $hash) { + $validator = Validator::make($request->all(), [ + 'tarefa' => "required|string" + ]); + + // Verifica se a validação falhou + if ($validator->fails()) { + return response()->json(['errors' => $validator->errors()], 422); + } + $chat = Gemini::chat() ->startChat(history: [ // Content::parse(part: 'Suas respostas serão curtas'), @@ -35,10 +45,34 @@ public function tasks(Request $request, Usuario $hash) $response = $chat->sendMessage("input:" . $tarefa . "\n output:"); return response()->json(json_decode($response->text()), 200); } catch (\Throwable $th) { - return response()->json(['data' => "não foi possivel responder seu prompt. Verifique o conteudo ou se o formato está correto"], 400); + return response()->json(['data' => $th->getMessage()], 400); } } + + public function gutSugest(Request $request, Usuario $hash) + { + + $chat = Gemini::chat() + ->startChat(history: [ + // Content::parse(part: 'Suas respostas serão curtas'), + Content::parse(part: "Pontue a gravidade, urgencia e tendencia das tarefas a seguir. A gravidade significa o quão importante uma tarefa é, a urgencia significa o quao rapido a tarefa precisa ser feita e a tendencia é o quanto pode ser problematico se a tarefa não for resolvida no futuro. Os valores devem ser de 1 a 5 voce não deve dar informações adicionais. Sua resposta deve estar no formato JSON"), + Content::parse(part: "input: Concertar maquina de café"), + Content::parse(part: 'output: {"gravidade": 3,"urgencia": 2,"tendencia": 3}'), + Content::parse(part: "input: Contratar mais funcionarios"), + Content::parse(part: 'output: {"gravidade": 1,"urgencia": 1,"tendencia": 1}'), + ]); + + try { + $tarefa = $request->input('tarefa'); + if (empty($tarefa)) throw new Exception(); + $response = $chat->sendMessage("input:" . $tarefa . "\n output:"); + return response()->json(json_decode($response->text()), 200); + } catch (\Throwable $th) { + return response()->json(['data' => "não foi possivel responder seu prompt. Verifique o conteudo ou se o formato está correto"], 400); + + } + } } diff --git a/routes/api.php b/routes/api.php index eec98de..c88bc62 100644 --- a/routes/api.php +++ b/routes/api.php @@ -66,12 +66,13 @@ // Define uma rota GET para retornar lista de empresas a partir da id do usuário parceiro Route::get('partner/{hash}', 'partnerCompanies'); - // Define uma rota GET para exibir uma empresa específica - Route::get('{empresa}/', 'show'); - + // Define uma rota GET para listar todas as tarefas e subtarefas a partir de uma empresa - Route::get('{empresa}/tarefas/', 'companieTasks'); + Route::get('{empresa}/tarefas/{hash}', 'companieTasks'); + // Define uma rota GET para exibir uma empresa específica + Route::get('{empresa}/{hash}', 'show'); + // Define uma rota POST para criar uma nova empresa Route::post('{hash}', 'store'); @@ -96,4 +97,5 @@ // IA // Route::get('/gemini', [GeminiController::class, 'index']); -Route::post('/IA/{hash}', [GeminiController::class, 'tasks']); +Route::post('/IA/tarefas/{hash}', [GeminiController::class, 'tasks']); +Route::post('/IA/gut/{hash}', [GeminiController::class,'gutSugest']); \ No newline at end of file From 473fab18828ae77f4dc7976b524e250037665d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Tue, 11 Jun 2024 02:11:52 -0300 Subject: [PATCH 4/6] =?UTF-8?q?ajustes=20na=20fun=C3=A7=C3=A3o=20de=20reto?= =?UTF-8?q?rnar=20tarefas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmpresaController.php | 5 ++--- app/Models/Subtarefa.php | 4 ++-- app/Models/Tarefa.php | 5 +++++ database/factories/SubtarefaFactory.php | 4 ++-- .../migrations/2024_06_10_141435_create_subtarefas_table.php | 2 +- database/seeders/DatabaseSeeder.php | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index b2b8f55..5a12af4 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -80,10 +80,9 @@ function companieTasks(Empresa $empresa, Usuario $hash) { //retornar tarefas e subtarefas da empresa recebida como parametro. + $tarefas = $empresa->t5w2hs()->distinct()->get(['tarefa_id']); + return $tarefas->load('tarefa.subtarefas:tarefa_id,subtarefa'); - return T5w2h::with('subtarefas:id,5w2h_id,subtarefa') - ->whereBelongsTo($empresa) - ->get(['id', 'empresa_id', 'tarefa']); } public function show(string $empresaId, string $userHash) diff --git a/app/Models/Subtarefa.php b/app/Models/Subtarefa.php index 267ad3b..440a2b4 100644 --- a/app/Models/Subtarefa.php +++ b/app/Models/Subtarefa.php @@ -14,7 +14,7 @@ function usuario() : BelongsTo { return $this->belongsTo(Usuario::class)->withDefault(); } - function t5w2h() : BelongsTo { - return $this->belongsTo(T5w2h::class, '5w2h_id')->withDefault(); + function tarefa() : BelongsTo { + return $this->belongsTo(Tarefa::class)->withDefault(); } } diff --git a/app/Models/Tarefa.php b/app/Models/Tarefa.php index afe9f0d..062773c 100644 --- a/app/Models/Tarefa.php +++ b/app/Models/Tarefa.php @@ -17,4 +17,9 @@ public function t5w2hs(): HasMany { return $this->hasMany(T5w2h::class); } + + public function subtarefas(): HasMany + { + return $this->hasMany(Subtarefa::class); + } } diff --git a/database/factories/SubtarefaFactory.php b/database/factories/SubtarefaFactory.php index b99eb5d..9808dfc 100644 --- a/database/factories/SubtarefaFactory.php +++ b/database/factories/SubtarefaFactory.php @@ -2,7 +2,7 @@ namespace Database\Factories; -use App\Models\T5w2h; +use App\Models\Tarefa; use App\Models\Usuario; use Illuminate\Database\Eloquent\Factories\Factory; @@ -20,7 +20,7 @@ public function definition(): array { return [ 'usuario_id' => Usuario::all()->random()->id, - '5w2h_id' => T5w2h::all()->random()->id, + 'tarefa_id' => Tarefa::all()->random()->id, 'subtarefa' => fake()->sentence() ]; } diff --git a/database/migrations/2024_06_10_141435_create_subtarefas_table.php b/database/migrations/2024_06_10_141435_create_subtarefas_table.php index 81a8940..f49df26 100644 --- a/database/migrations/2024_06_10_141435_create_subtarefas_table.php +++ b/database/migrations/2024_06_10_141435_create_subtarefas_table.php @@ -15,7 +15,7 @@ public function up(): void $table->id(); $table->string('usuario_id'); $table->foreign('usuario_id')->references('id')->on('usuarios'); - $table->foreignId('5w2h_id')->references('id')->on('t5w2hs'); + $table->foreignId('tarefa_id')->references('id')->on('tarefas'); $table->string('subtarefa'); $table->timestamps(); }); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index df8d563..91dd536 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -55,7 +55,7 @@ public function run(): void }); - Subtarefa::factory(5)->create(); + Subtarefa::factory(25)->create(); //Gut::factory(5)->create(); } } From 835f060b41de78406da59428021458b66c6f4b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Tue, 11 Jun 2024 04:23:19 -0300 Subject: [PATCH 5/6] atualizando readme --- README.md | 288 +++++++++--------- app/Http/Controllers/EmpresaController.php | 8 +- ...4_06_10_141435_create_subtarefas_table.php | 4 +- routes/api.php | 13 +- 4 files changed, 165 insertions(+), 148 deletions(-) diff --git a/README.md b/README.md index 8e2a182..01e9e5d 100644 --- a/README.md +++ b/README.md @@ -283,29 +283,33 @@ Exemplo de requisição: POST /api/empresas/t5w2h/1/C5244i4950A5414f4792A486a5694 -[ - { - "pergunta_id": 1, - "resposta": "Abrir uma cafeteria", - "tarefa": "Pesquisar cafeterias" - }, - { - "pergunta_id": 2, - "resposta": "Ganhar dinheiro", - }, - { - "pergunta_id": 3, - "resposta": "Eu e dois funcionarios", - "tarefa": "Contratar funcionarios" - }, - { - "pergunta_id": 4, - "resposta": "5 mil pilas", - "tarefa": "Economizar dinheiro" - } -] +{ + "tarefa": "Está é a nossa nova tarefa", + "gut": { + "gravidade": 2, + "urgencia": 2, + "tendencia": 4 + }, + "respostas": [ + { + "pergunta_id": 1, + "resposta": "Ser uma pessoa melhor" + }, + { + "pergunta_id": 2, + "resposta": "Por que a vida é curta" + } + ] +} +``` +retorno + +``` +{ + "success": "Registros feitos com sucesso", + "tarefa_id": 12 +} ``` -Observe que a tarefa pode ser omitida. O que o id de cada pergunta representa: @@ -358,26 +362,26 @@ Exemplo: GET api/empresas/partner/{hash} [ - { - "id": 1, - "usuario_id": "I4949A5348H4674F5182i570", - "nome_da_empresa": "Vieira-da Silva", - "nicho": "qui", - "resumo": "Cabral falara da minha consciencia moral sem _deficit._ Mandar dizer cem missas, ou subir do joelhos a ladeira da Gloria para ouvir uma, ir á Terra-Santa, tudo o que tanto póde ser que não se.", - "created_at": "2024-05-13T13:36:10.000000Z", - "updated_at": "2024-05-13T13:36:10.000000Z", - "pivot": {...} - }, - { - "id": 2, - "usuario_id": "I4949A5348H4674F5182i570", - "nome_da_empresa": "Solano Comercial Ltda.", - "nicho": "eum", - "resumo": "As mãos, a despeito de alguns instantes de concentrarão, veiu ver se eram adequadas e se ajoelhavam á nossa passagem, tudo me enchia a alma de lepidez nova. Padua, ao contrario, os olhos para elles.", - "created_at": "2024-05-13T13:36:10.000000Z", - "updated_at": "2024-05-13T13:36:10.000000Z", - "pivot": {...} - } + { + "id": 1, + "usuario_id": "I4949A5348H4674F5182i570", + "nome_da_empresa": "Vieira-da Silva", + "nicho": "qui", + "resumo": "Cabral falara da minha consciencia moral sem _deficit._ Mandar dizer cem missas, ou subir do joelhos a ladeira da Gloria para ouvir uma, ir á Terra-Santa, tudo o que tanto póde ser que não se.", + "created_at": "2024-05-13T13:36:10.000000Z", + "updated_at": "2024-05-13T13:36:10.000000Z", + "pivot": {...} + }, + { + "id": 2, + "usuario_id": "I4949A5348H4674F5182i570", + "nome_da_empresa": "Solano Comercial Ltda.", + "nicho": "eum", + "resumo": "As mãos, a despeito de alguns instantes de concentrarão, veiu ver se eram adequadas e se ajoelhavam á nossa passagem, tudo me enchia a alma de lepidez nova. Padua, ao contrario, os olhos para elles.", + "created_at": "2024-05-13T13:36:10.000000Z", + "updated_at": "2024-05-13T13:36:10.000000Z", + "pivot": {...} + } ] ``` @@ -390,127 +394,109 @@ Exemplo: GET /api/empresas/1/tarefas/I4949A5348H4674F5182i570 [ - { - "id": 1, - "empresa_id": 1, - "tarefa": "Omnis autem laudantium quis maxime repudiandae tempore consequatur.", - "subtarefas": [] - }, - { - "id": 2, - "empresa_id": 1, - "tarefa": "Dignissimos quia nam ut et fuga voluptas enim.", - "subtarefas": [] - }, - { - "id": 3, - "empresa_id": 1, - "tarefa": "Nihil aliquid nisi alias quia quod quo.", - "subtarefas": [] - }, - { - "id": 4, - "empresa_id": 1, - "tarefa": "Illo sed minus placeat consequatur sequi sunt dolorum.", - "subtarefas": [] - }, - { - "id": 5, - "empresa_id": 1, - "tarefa": "Qui recusandae amet laborum impedit consequatur.", - "subtarefas": [] - }, - { - "id": 6, - "empresa_id": 1, - "tarefa": "Nemo aut et cupiditate commodi alias.", - "subtarefas": [] - }, - { - "id": 7, - "empresa_id": 1, - "tarefa": "Veritatis dicta animi numquam quia reiciendis beatae.", - "subtarefas": [ - { - "id": 2, - "5w2h_id": 7, - "subtarefa": "Veniam fugiat ipsam nihil fugiat." - } - ] - } + { + "tarefa_id": 11, + "tarefa": { + "id": 11, + "descrição": "Está é a nossa tarefa", + "created_at": "2024-06-11T04:47:57.000000Z", + "updated_at": "2024-06-11T04:47:57.000000Z", + "subtarefas": [] + } + }, + { + "tarefa_id": 12, + "tarefa": { + "id": 12, + "descrição": "Está é a nossa nova tarefa", + "created_at": "2024-06-11T04:48:08.000000Z", + "updated_at": "2024-06-11T04:48:08.000000Z", + "subtarefas": [ + { + "tarefa_id": 12, + "subtarefa": "Comprar mais café" + }, + { + "tarefa_id": 12, + "subtarefa": "Comprar mais pessoas" + } + ] + } + } ] ``` Nem toda tarefa tem subtarefas. -### Registrando tabela GUT -Para registrar a tabela GUT é necesssario fazer uma requisição POST na rota `api/gut/{empresa}/{hash}`, onde os parametros são id da empresa e do usuario respectivamente. +### Recuperando dados da 5w2h -O corpo da requisição deve conter um array de até 7 dicionarios onde `pergunta_id` representa o id da pergunta que gerou a tarefa que está sendo analisada, e `gut` um vetor que representa os valores para gravidade, urgencia e tendencia. +Para listar os dados da 5w2h de uma empresa faça uma requisição GET na rota `api/empresas/t5w2h/{empresa}/{hash}`, `{empresa}`é o id da empresa e `{hash}` é o id do usuario. - - - -Exemplo de corpo: +O exemplo a baixo só tem duas tarefas ``` -POST +GET api/empresas/t5w2h/10/D5218A4981c4653c518A540 + [ - { - "pergunta_id": 1, - "gut" : [4, 5, 1] - }, - { - "pergunta_id": 2, - "gut" : [1, 2, 3] - }, - { - "pergunta_id": 3, - "gut" : [3, 3, 3] - }, { - "pergunta_id": 4, - "gut" : [2, 2, 2] - }, - { - "pergunta_id": 5, - "gut" : [4, 3, 1] - }, - { - "pergunta_id": 6, - "gut" : [1, 1, 1] - }, + "id": 64, + "empresa_id": 10, + "tarefa_id": 10, + "pergunta_id": 1, + "gut_id": 10, + "resposta": "Et quibusdam eius ducimus dolores explicabo.", + "tarefa": { + "id": 10, + "descrição": "Eius fugit est similique et minus." + }, + "pergunta": { + "id": 1, + "pergunta": "O quê" + }, + "gut": { + "id": 10, + "gravidade": 4, + "urgencia": 4, + "tendencia": 2 + } + }, { - "pergunta_id": 7, - "gut" : [1, 1, 2] - } + "id": 65, + "empresa_id": 10, + "tarefa_id": 10, + "pergunta_id": 2, + "gut_id": 10, + "resposta": "Beatae voluptates facilis voluptas est maxime.", + "tarefa": { + "id": 10, + "descrição": "Eius fugit est similique et minus." + }, + "pergunta": { + "id": 2, + "pergunta": "Por que" + }, + "gut": { + "id": 10, + "gravidade": 4, + "urgencia": 4, + "tendencia": 2 + } + } ] ``` +### Deletar tarefas na 5w2h -Pergunta que cada id representa: - -``` -[ - 1 => 'O quê', - 2 => 'Por que', - 3 => 'Quem', - 4 => 'Quanto', - 5 => 'Como', - 6 => 'Quando', - 7 => 'Onde' -] -``` +Faça uma requisição DELETE na rota `api/empresas/t5w2h/{tarefa}/{hash}` para deletar registros associados a uma tarefa na tabela 5w2h. `{tarefa}` representa o id da tarefa e `{hash}` o id do usuario. -Resultado esperado: +retorno ``` -HTTP/1.1 200 OK - { - "sucesso": "Gut cadastrado com sucesso" + "success": "Dados deletados com sucesso" } ``` + ### Requerir tarefas da IA #### Atenção! É necessario informar uma chave valida para a api do Gemini. @@ -549,6 +535,26 @@ Resposta: ] ``` +### Requerir sugestões de GUT com IA +Para receber uma sugestão de gut para determinada tarefa, faça uma requisição POST na rota `api/IA/gut/{hash}` onde `{hash}` é o id do usuario. + +exemplo +``` +POST /api/IA/gut/d4924A4965A4683H5339a510 +{ + "tarefa": "Comprar café para consumo pessoal" +} +``` +retorno + +``` +{ + "gravidade": 2, + "urgencia": 1, + "tendencia": 1 +} +``` + ### Como criar banco de dados e popular: Uma vez que a conexão com o banco de dados estiver configurada, o primeiro comando a ser utilizado é: diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index 5a12af4..a81f945 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -73,7 +73,7 @@ function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) $t5w2h->gut()->associate($gut); $t5w2h->save(); } - return response()->json(['success' => 'Registros feitos com sucesso'], 201); + return response()->json(['success' => 'Registros feitos com sucesso', "tarefa_id" => $tarefa->id], 201); } function companieTasks(Empresa $empresa, Usuario $hash) @@ -192,6 +192,12 @@ public function update(Request $request, string $empresaId, string $userHash) return response()->json(['errors' => 'Erro ao atualizar registro'], 400); } + public function destroyT5w2h(Tarefa $tarefa, Usuario $usuario) + { + $tarefa->t5w2hs()->delete(); + return response()->json(['success' => 'Dados deletados com sucesso'], 200); + } + public function destroy(string $empresaId, string $userHash) { /** diff --git a/database/migrations/2024_06_10_141435_create_subtarefas_table.php b/database/migrations/2024_06_10_141435_create_subtarefas_table.php index f49df26..7d66b69 100644 --- a/database/migrations/2024_06_10_141435_create_subtarefas_table.php +++ b/database/migrations/2024_06_10_141435_create_subtarefas_table.php @@ -14,8 +14,8 @@ public function up(): void Schema::create('subtarefas', function (Blueprint $table) { $table->id(); $table->string('usuario_id'); - $table->foreign('usuario_id')->references('id')->on('usuarios'); - $table->foreignId('tarefa_id')->references('id')->on('tarefas'); + $table->foreign('usuario_id')->references('id')->on('usuarios')->onDelete('cascade'); + $table->foreignId('tarefa_id')->references('id')->on('tarefas')->onDelete('cascade'); $table->string('subtarefa'); $table->timestamps(); }); diff --git a/routes/api.php b/routes/api.php index c88bc62..114777a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -60,19 +60,24 @@ // Define uma rota GET para listar registros da 5w2h Route::get('t5w2h/{empresa}/{hash}', 'showT5w2h'); - // Define um rota POST para fazer registros nas tabela 5w2h da empresa + // Define uma rota POST para fazer registros nas tabela 5w2h da empresa Route::post('t5w2h/{empresa}/{hash}', 'storeT5w2h'); + // // Define uma rota PUT para atualizar registros nas tabela 5w2h da empresa + // Route::put('t5w2h/{empresa}/{hash}', 'storeT5w2h'); + + // Define uma rota DELETE para deletar registros associados a uma tarefa na tabela 5w2h + Route::delete('t5w2h/{tarefa}/{hash}', 'destroyT5w2h'); // Define uma rota GET para retornar lista de empresas a partir da id do usuário parceiro Route::get('partner/{hash}', 'partnerCompanies'); - + // Define uma rota GET para listar todas as tarefas e subtarefas a partir de uma empresa Route::get('{empresa}/tarefas/{hash}', 'companieTasks'); // Define uma rota GET para exibir uma empresa específica Route::get('{empresa}/{hash}', 'show'); - + // Define uma rota POST para criar uma nova empresa Route::post('{hash}', 'store'); @@ -98,4 +103,4 @@ // Route::get('/gemini', [GeminiController::class, 'index']); Route::post('/IA/tarefas/{hash}', [GeminiController::class, 'tasks']); -Route::post('/IA/gut/{hash}', [GeminiController::class,'gutSugest']); \ No newline at end of file +Route::post('/IA/gut/{hash}', [GeminiController::class, 'gutSugest']); \ No newline at end of file From fef8001a614f3190d544541844f11fa16b59d4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Ribeiro=20Santos?= Date: Tue, 11 Jun 2024 11:38:42 -0300 Subject: [PATCH 6/6] =?UTF-8?q?fun=C3=A7=C3=A3o=20de=20inserir=20gut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +++++++++++++ app/Http/Controllers/EmpresaController.php | 18 ++++++--- app/Http/Controllers/GutController.php | 46 ++++++++-------------- routes/api.php | 4 +- 4 files changed, 58 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 01e9e5d..30f9414 100644 --- a/README.md +++ b/README.md @@ -497,6 +497,33 @@ retorno } ``` +### Registrando tabela GUT +Para registrar a tabela GUT é necesssario fazer uma requisição POST na rota `api/gut/{tarefa}/{hash}`, onde os parametros são id da tarefa e do usuario respectivamente. + + +Exemplo de corpo: + +``` +POST + +{ + "gravidade": 1, + "urgencia": 1, + "tendencia": 1 +} +``` + + +Resultado esperado: + +``` +HTTP/1.1 200 OK + +{ + "sucesso": "Gut cadastrado com sucesso" +} +``` + ### Requerir tarefas da IA #### Atenção! É necessario informar uma chave valida para a api do Gemini. diff --git a/app/Http/Controllers/EmpresaController.php b/app/Http/Controllers/EmpresaController.php index a81f945..7e4f2d0 100644 --- a/app/Http/Controllers/EmpresaController.php +++ b/app/Http/Controllers/EmpresaController.php @@ -10,6 +10,7 @@ use App\Models\Empresa; use App\Models\T5w2h; use App\Models\Usuario; +use Illuminate\Support\Fluent; class EmpresaController extends Controller { @@ -54,24 +55,29 @@ function storeT5w2h(Request $request, Empresa $empresa, Usuario $hash) $validator = Validator::make($contents, [ "tarefa" => "required|string", - "gut.gravidade"=> "required", - "gut.urgencia"=> "required", - "gut.tendencia"=> "required", + "gut" => "nullable", "respostas.*.pergunta_id" => "required|int", "respostas.*.resposta" => "required|string", ]); + $validator = $validator->sometimes(['gut.gravidade', 'gut.urgencia', 'gut.tendencia'], 'required', function (Fluent $input) { + return isset($input->gut); + }); if ($validator->fails()) { return response()->json(['errors' => $validator->errors()], 422); } $tarefa = Tarefa::firstOrCreate(["descrição"=> $contents["tarefa"]]); - $gut = Gut::firstOrCreate($request['gut']); + if ($request['gut']) + $gut = Gut::firstOrCreate($request['gut']); foreach ($contents["respostas"] as $resposta) { $t5w2h = T5w2h::updateOrCreate(["empresa_id" => $empresa->id, "pergunta_id" => $resposta["pergunta_id"], "tarefa_id" => $tarefa->id], ["resposta" => $resposta['resposta']]); - $t5w2h->gut()->associate($gut); - $t5w2h->save(); + if ($request['gut']) + { + $t5w2h->gut()->associate($gut); + $t5w2h->save(); + } } return response()->json(['success' => 'Registros feitos com sucesso', "tarefa_id" => $tarefa->id], 201); } diff --git a/app/Http/Controllers/GutController.php b/app/Http/Controllers/GutController.php index df33988..a209b7c 100644 --- a/app/Http/Controllers/GutController.php +++ b/app/Http/Controllers/GutController.php @@ -5,8 +5,10 @@ use App\Models\Empresa; use App\Models\Gut; use App\Models\T5w2h; +use App\Models\Tarefa; use App\Models\Usuario; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; class GutController extends Controller { @@ -14,42 +16,28 @@ class GutController extends Controller * Armazena uma nova GUT. * Retorna um erro 404 automaticamente se a empresa ou o usuario não forem encontrados. * @param Illuminate\Http\Request $request - * @param App\Models\Empresa $empresa + * @param App\Models\\Tarefa $tarefa * @param App\Models\Usuario $hash */ - function store(Request $request, Empresa $empresa, Usuario $hash) + function store(Request $request, Tarefa $tarefa, Usuario $hash) { - $t5w2hs = $empresa->t5w2hs; - $gutArray = array(); - //Coleta o conteudo do $request e armazena num array de Guts - for ($i = 0; $i < count($request->all()); $i++) { - $gut = new Gut( - [ - 'gravidade' => $request->input($i . ".gut.0"), - 'urgencia' => $request->input($i . ".gut.1"), - 'tendencia' => $request->input($i . ".gut.2") - ] - ); - $gutArray[$i]['gut'] = $gut; - $gutArray[$i]['total'] = $gut->gravidade * $gut->urgencia * $gut->tendencia; - } - // Ordena o array com base no total de pontos - usort($gutArray, function ($a, $b) { - if ($a['total'] == $b['total']) { - return 0; - } - return ($a['total'] > $b['total']) ? -1 : 1; - }); + $validator = Validator::make($request->all(), [ + "gravidade" => "required|int", + "urgencia" => "required|int", + "tendencia" => "required|int" + ]); - //Insere cada gut associando com sua respectiva linha na tabela 5w2h - for ($i = 0; $i < count($request->all()); $i++) { - $t5w2hs->where('pergunta_id', $request->input($i . ".pergunta_id")) - ->first() - ->gut() - ->save($gutArray[$i]['gut']); + if ($validator->fails()) { + return response()->json(['errors' => $validator->errors()], 422); } + $gut = Gut::firstOrCreate($validator->validated()); + $t5w2h = $tarefa->t5w2hs; + $t5w2h->each(function (T5w2h $t5w2h) use ($gut) { + $gut = $t5w2h->gut()->associate($gut); + $gut->save(); + }); return response()->json(['sucesso' => 'Gut cadastrado com sucesso'], 200); } diff --git a/routes/api.php b/routes/api.php index 114777a..6c58bc2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -64,7 +64,7 @@ Route::post('t5w2h/{empresa}/{hash}', 'storeT5w2h'); // // Define uma rota PUT para atualizar registros nas tabela 5w2h da empresa - // Route::put('t5w2h/{empresa}/{hash}', 'storeT5w2h'); + Route::put('t5w2h/{empresa}/{hash}', 'updateT5w2h'); // Define uma rota DELETE para deletar registros associados a uma tarefa na tabela 5w2h Route::delete('t5w2h/{tarefa}/{hash}', 'destroyT5w2h'); @@ -94,7 +94,7 @@ // As rotas autocamticamente chamam métodos na GutController // Define uma rota POST para criar um novo gut - Route::post('{empresa}/{hash}', 'store'); + Route::post('{tarefa}/{hash}', 'store'); });