Desarrollo del modulo de alumno y control escolar para subir archivos de expediente

This commit is contained in:
2026-03-26 17:36:09 -06:00
parent 1bcebeb8a1
commit 3061a64418
137 changed files with 7234 additions and 57 deletions
-1
View File
@@ -3,7 +3,6 @@
namespace App\Actions\Fortify;
use App\Models\Alumno;
use App\Models\Prospecto;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Auth;
@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers;
use App\Models\Alumno;
use App\Models\Documento;
use Illuminate\Http\Request;
class DocumentoController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$request->validate([
'curp' => 'file|mimes:pdf,jpg,png',
'acta' => 'file|mimes:pdf,jpg,png',
'comprobante' => 'file|mimes:pdf,jpg,png',
]);
$alumno = Alumno::findOrFail($request->alumno_id);
$tipos = ['curp', 'acta', 'comprobante'];
foreach ($tipos as $tipo) {
if ($request->hasFile($tipo)) {
$ruta = $request->file($tipo)->store('documentos', 'public');
$alumno->documentos()->create([
'tipo' => $tipo,
'archivo' => $ruta
]);
}
}
return back()->with('success', 'Documentos subidos correctamente');
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
public function ver($id)
{
$doc = Documento::findOrFail($id);
if (
!auth()->user()->hasRole('Alumno') &&
!auth()->user()->hasRole('Promotor') &&
!auth()->user()->hasRole('Control escolar')
) {
abort(403);
}
return response()->file(storage_path('app/public/'.$doc->archivo));
}
}
+59 -10
View File
@@ -3,21 +3,22 @@
namespace App\Livewire;
use App\Models\Alumno;
use App\Models\Pago;
use App\Models\Plan;
use App\Models\Campan;
use App\Models\Concepto;
use App\Models\Documento;
use App\Models\Medio;
use App\Models\Nivel;
use App\Models\Pago;
use App\Models\Plan;
use App\Models\Plane;
use App\Models\Turno;
use App\Models\Campan;
use App\Models\Plantel;
use Livewire\Component;
use App\Models\Concepto;
use Livewire\Attributes\On;
use Illuminate\Validation\Rule;
use App\Models\Role;
use App\Models\Turno;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\On;
use Livewire\Component;
class DataProspecto extends Component
{
@@ -53,7 +54,9 @@ class DataProspecto extends Component
public $active = "disabled";
public $prospecto = null;
public $prospecto;
public $documentoSeleccionado;
public function failedValidation(ValidationException $e)
{
@@ -69,6 +72,52 @@ class DataProspecto extends Component
throw $e;
}
#[On('set-documento')]
public function setDocumento($id)
{
$this->documentoSeleccionado = $id;
}
public function aprobarDocumento()
{
if (!$this->documentoSeleccionado) return;
Documento::where('id', $this->documentoSeleccionado)
->update(['status' => 1]);
$this->dispatch('cerrar-modal');
$this->dispatch('swal',
icon: 'success',
title: 'Validádo',
text: 'notificado',
timer: 2000,
confirm: false,
closeModal: true
);
$this->prospecto->refresh();
}
public function rechazarDocumento()
{
if (!$this->documentoSeleccionado) return;
Documento::where('id', $this->documentoSeleccionado)
->update(['status' => 2]);
$this->dispatch('cerrar-modal');
$this->dispatch('swal',
icon: 'error',
title: 'Rechazado',
text: 'notificado',
timer: 2000,
confirm: false,
closeModal: true
);
$this->prospecto->refresh();
}
public function updatedPplantels()
{
$this->selectedNivel = null;
@@ -219,7 +268,7 @@ class DataProspecto extends Component
$this->pname = $user->name;
$this->papellidoPaterno = $user->apellidoPaterno;
$this->papellidoMaterno = $user->apellidoPaterno;
$this->papellidoMaterno = $user->apellidoMaterno;
$this->pemail = $user->email;
$this->ptelefono = $user->telefono;
$this->pdireccion = $user->direccion;
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\Livewire;
use App\Models\Alumno;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\On;
use Livewire\Component;
use Livewire\WithFileUploads;
class Documentos extends Component
{
use WithFileUploads;
public $curp;
public $acta;
public $comprobante;
public $user;
public $alumno;
public $documentosPorTipo = [];
#[On('documentos')]
public function documentos()
{
$this->dispatch('open-documentos-modal');
}
public function cargarDocumentos()
{
$this->alumno = Auth::user()->alumnos()->first();
if ($this->alumno) {
$this->documentosPorTipo = $this->alumno
->documentos()
->get()
->keyBy('tipo');
}
}
public function store()
{
$this->validate([
'curp' => 'nullable|file|mimes:pdf,jpg,png',
'acta' => 'nullable|file|mimes:pdf,jpg,png',
'comprobante' => 'nullable|file|mimes:pdf,jpg,png',
]);
$alumno = Auth::user()->alumnos->first();
if (!$alumno) {
abort(404, 'Alumno no encontrado');
}
$tipos = ['curp', 'acta', 'comprobante'];
foreach ($tipos as $tipo) {
if ($this->$tipo) {
$ruta = $this->$tipo->store('documentos', 'public');
$alumno->documentos()->updateOrCreate(
['tipo' => $tipo],
[
'archivo' => $ruta,
'status' => 0
]
);
}
}
// 🔥 recargar correctamente
$this->cargarDocumentos();
$this->reset(['curp', 'acta', 'comprobante']);
$this->dispatch('close-documentos-modal');
$this->dispatch('swal',
icon: 'success',
title: 'Éxito!',
text: 'Documentos cargados',
timer: 2000,
confirm: false,
closeModal: true,
reload: 2000
);
}
public function mount()
{
$this->cargarDocumentos();
}
public function render()
{
return view('livewire.documentos');
}
}
+5
View File
@@ -47,4 +47,9 @@ class Alumno extends Model
return $this->belongsTo(Nivel::class, 'nivel');
}
public function documentos()
{
return $this->hasMany(Documento::class);
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Documento extends Model
{
protected $fillable = [
'alumno_id',
'tipo',
'archivo',
'status'
];
public function alumno()
{
return $this->belongsTo(Alumno::class);
}
}