diff --git a/app/Http/Controllers/AlunosController.php b/app/Http/Controllers/AlunosController.php new file mode 100644 index 0000000..2acbb1b --- /dev/null +++ b/app/Http/Controllers/AlunosController.php @@ -0,0 +1,30 @@ +id_escola; + if ($escolaId == 0) { + $alunos = alunos::all(); + } else { + $alunos = []; + $turmas = turmas::where('id_escola', $escolaId)->get(); + foreach ($turmas as $turma) { + $alunosget = alunos::where('id_turma', $turma->id)->get(); + + foreach ($alunosget as $alunosg) { + $alunos[] = $alunosg; + } + } + } + return view('escolas.alunos', compact('alunos')); + } +} diff --git a/app/Http/Controllers/EnvioWhatsap.php b/app/Http/Controllers/EnvioWhatsap.php new file mode 100644 index 0000000..80d761b --- /dev/null +++ b/app/Http/Controllers/EnvioWhatsap.php @@ -0,0 +1,61 @@ +validate([ + 'id_turma' => 'required|exists:turmas,id', + 'tipo_envio' => 'required|in:texto,imagem', + 'mensagem' => 'nullable|string', + 'imagem' => 'required_if:tipo_envio,imagem|image|mimes:jpeg,png,webp|max:2048', + ]); + + $turma = turmas::findOrFail($request->id_turma); + + // Corrigir formatação para WhatsApp + $mensagem = $request->mensagem ?? ''; + $mensagem = str_replace(['**', '__', '~~'], ['*', '_', '~'], $mensagem); + + $payload = [ + 'chatId' => $turma->id_whatsapp, + 'mensagem' => $mensagem, + ]; + + // ✅ Se for envio com imagem + if ($request->tipo_envio === 'imagem' && $request->hasFile('imagem')) { + + $file = $request->file('imagem'); + + $base64 = base64_encode( + file_get_contents($file->getRealPath()) + ); + + $mime = $file->getMimeType(); // image/png, image/jpeg, etc + + // 🔥 AQUI está o prefixo obrigatório + $base64Completo = "data:$mime;base64,$base64"; + + $payload['imagem'] = $base64Completo; + } + + // ✅ Enviar para API + $response = Http::withHeaders([ + 'X-API-KEY' => 'UoCkSF4ApgADhpvDkkE5XO1fD761yOZX', + 'Content-Type' => 'application/json', + ])->post('https://n8n.cae.app.br/webhook/envioWpp', $payload); + + // ✅ Retorno amigável + if ($response->successful()) { + return back()->with('success', 'Mensagem enviada com sucesso!'); + } + + return back()->with('error', 'Erro ao enviar: ' . $response->body()); + } +} diff --git a/app/Http/Controllers/EscolasController.php b/app/Http/Controllers/EscolasController.php new file mode 100644 index 0000000..aa34791 --- /dev/null +++ b/app/Http/Controllers/EscolasController.php @@ -0,0 +1,37 @@ +id_escola == 0) { + $escolas = escolas::all(); + } else { + $escolas = escolas::where('id', Auth::user()->id_escola)->get(); + } + + return view('escolas.index', compact('escolas')); + } + + public function createOrUpdate(Request $request) + { + try { + escolas::updateOrCreate([ + 'cnpj' => $request->cnpj, + ],[ + 'nome' => $request->razaosocial, + 'endereco' => json_decode($request->address, true), + ]); + return redirect()->route('escolas')->with('success', 'Escola Criada|Atualizada com sucesso'); + } catch (\Throwable $th) { + dd($th); + } + } +} diff --git a/app/Http/Controllers/HistoricoEscolarController.php b/app/Http/Controllers/HistoricoEscolarController.php new file mode 100644 index 0000000..51b9c0f --- /dev/null +++ b/app/Http/Controllers/HistoricoEscolarController.php @@ -0,0 +1,10 @@ +id_escola == 0) { + $turmas = turmas::all(); + } else { + $turmas = turmas::where('id_escola', Auth::user()->id_escola)->get(); + } + + return view('escolas.turmas', compact('turmas')); + } + + public function createOrUpdate(Request $request) + { + $turma = turmas::where('nome', '=', $request->turma_nome)->count(); + if ($turma == 0) { + try { + $turma = new turmas(); + $turma->id_escola = $request->id_escola; + $turma->nome = $request->turma_nome; + $turma->descricao = $request->turma_descricao; + $turma->id_whatsapp = $request->id_whatsapp; + $turma->save(); + return redirect()->route('turmas')->with('success', 'Turma Criada|Atualizada com sucesso.'); + } catch (\Throwable $th) { + dd($th); + } + } else { + try { + turmas::where('nome', $request->turma_nome)->update([ + 'nome' => $request->turma_nome, + 'descricao' => $request->turma_descricao, + 'id_escola' => $request->id_escola, + 'id_whatsapp' => $request->id_whatsapp, + ]); + return redirect()->route('turmas')->with('success', 'Turma Criada|Atualizada com sucesso.'); + } catch (\Throwable $th) { + //throw $th; + } + } + } +} diff --git a/app/Models/alunos.php b/app/Models/alunos.php new file mode 100644 index 0000000..4319757 --- /dev/null +++ b/app/Models/alunos.php @@ -0,0 +1,17 @@ +belongsTo(turmas::class, 'id_turma', 'id'); + } + + public function responsaveis() { + return $this->hasMany(User::class, 'id', 'id_responsavel'); + } +} diff --git a/app/Models/escolas.php b/app/Models/escolas.php new file mode 100644 index 0000000..0f561ac --- /dev/null +++ b/app/Models/escolas.php @@ -0,0 +1,23 @@ + 'array', + ]; + + protected $fillable = [ + 'cnpj', + 'endereco', + 'nome', + ]; + + public function turmas() + { + return $this->hasMany(turmas::class, 'id_escola', 'id'); + } +} diff --git a/app/Models/historico_escolar.php b/app/Models/historico_escolar.php new file mode 100644 index 0000000..b7e4875 --- /dev/null +++ b/app/Models/historico_escolar.php @@ -0,0 +1,10 @@ +hasOne(escolas::class, 'id', 'id_escola'); + } + + public function alunos() + { + return $this->hasMany(alunos::class, 'id', 'id_turma'); + } +} diff --git a/database/migrations/2026_02_06_145300_add_inf_users.php b/database/migrations/2026_02_06_145300_add_inf_users.php new file mode 100644 index 0000000..7ad2dd5 --- /dev/null +++ b/database/migrations/2026_02_06_145300_add_inf_users.php @@ -0,0 +1,31 @@ +integer('id_escola')->nullable(); + $table->string('profile')->nullable(); + $table->string('cpf')->nullable(); + $table->json('endereco')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2026_02_06_160406_change_inf_users.php b/database/migrations/2026_02_06_160406_change_inf_users.php new file mode 100644 index 0000000..b46e864 --- /dev/null +++ b/database/migrations/2026_02_06_160406_change_inf_users.php @@ -0,0 +1,30 @@ +integer('id_escola')->nullable()->after('created_at')->change(); + $table->string('profile')->nullable()->after('id_escola')->change(); + $table->string('cpf')->nullable()->after(column: 'profile')->change(); + $table->json('endereco')->nullable()->after('cpf')->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2026_02_06_160523_create_escolas_table.php b/database/migrations/2026_02_06_160523_create_escolas_table.php new file mode 100644 index 0000000..4248f35 --- /dev/null +++ b/database/migrations/2026_02_06_160523_create_escolas_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('cnpj')->unique(); + $table->string('nome'); + $table->json('endereco'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('escolas'); + } +}; diff --git a/database/migrations/2026_02_06_160529_create_turmas_table.php b/database/migrations/2026_02_06_160529_create_turmas_table.php new file mode 100644 index 0000000..cbb5602 --- /dev/null +++ b/database/migrations/2026_02_06_160529_create_turmas_table.php @@ -0,0 +1,30 @@ +id(); + $table->integer('id_escola'); + $table->string('nome'); + $table->string('descricao'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('turmas'); + } +}; diff --git a/database/migrations/2026_02_06_160539_create_alunos_table.php b/database/migrations/2026_02_06_160539_create_alunos_table.php new file mode 100644 index 0000000..fe49efe --- /dev/null +++ b/database/migrations/2026_02_06_160539_create_alunos_table.php @@ -0,0 +1,35 @@ +id(); + $table->integer('id_responsavel'); + $table->integer('id_turma'); + $table->string('nome'); + $table->date('data_nascimento'); + $table->date('data_inscricao'); + $table->date('data_encerramento'); + $table->string('cpf')->unique(); + $table->json('endereco'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('alunos'); + } +}; diff --git a/database/migrations/2026_02_06_160545_create_historico_escolars_table.php b/database/migrations/2026_02_06_160545_create_historico_escolars_table.php new file mode 100644 index 0000000..33fb674 --- /dev/null +++ b/database/migrations/2026_02_06_160545_create_historico_escolars_table.php @@ -0,0 +1,29 @@ +id(); + $table->integer('id_aluno'); + $table->longText('historico'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('historico_escolars'); + } +}; diff --git a/database/migrations/2026_02_09_175533_change_data_encerramento_alunos.php b/database/migrations/2026_02_09_175533_change_data_encerramento_alunos.php new file mode 100644 index 0000000..e63de2b --- /dev/null +++ b/database/migrations/2026_02_09_175533_change_data_encerramento_alunos.php @@ -0,0 +1,29 @@ +date('data_encerramento')->nullable()->change(); + $table->json('endereco')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('alunos', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2026_02_12_122819_add_wpp_id_to_turmas.php b/database/migrations/2026_02_12_122819_add_wpp_id_to_turmas.php new file mode 100644 index 0000000..1571221 --- /dev/null +++ b/database/migrations/2026_02_12_122819_add_wpp_id_to_turmas.php @@ -0,0 +1,28 @@ +string('id_whatsapp'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('turmas', function (Blueprint $table) { + // + }); + } +}; diff --git a/public/assets/css/bootstrap.css b/public/assets/css/bootstrap.css index 3cc9dd0..58a90ff 100644 --- a/public/assets/css/bootstrap.css +++ b/public/assets/css/bootstrap.css @@ -5099,6 +5099,20 @@ textarea.form-control-lg { border-top-width: 1px; } +.dropdown.show .gear-icon { + animation: spin 1.2s linear infinite; +} + +@keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + + .list-group-horizontal { -webkit-box-orient: horizontal; -webkit-box-direction: normal; diff --git a/public/assets/images/login.jpg b/public/assets/images/login.jpg new file mode 100644 index 0000000..5b5b1e7 Binary files /dev/null and b/public/assets/images/login.jpg differ diff --git a/public/assets/images/logo3.png b/public/assets/images/logo3.png new file mode 100644 index 0000000..e03014c Binary files /dev/null and b/public/assets/images/logo3.png differ diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 64769c9..fba39ae 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -12,7 +12,7 @@ -
