Commit ·
715309a
1
Parent(s): 70232e5
initial project
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- app/.env.example +59 -0
- app/.gitignore +49 -0
- app/app/Console/Kernel.php +27 -0
- app/app/Exceptions/Handler.php +30 -0
- app/app/Http/Controllers/AdminController.php +75 -0
- app/app/Http/Controllers/AlumnoController.php +327 -0
- app/app/Http/Controllers/Auth/ConfirmPasswordController.php +39 -0
- app/app/Http/Controllers/Auth/ForgotPasswordController.php +22 -0
- app/app/Http/Controllers/Auth/LoginController.php +51 -0
- app/app/Http/Controllers/Auth/RegisterController.php +74 -0
- app/app/Http/Controllers/Auth/ResetPasswordController.php +29 -0
- app/app/Http/Controllers/Auth/VerificationController.php +41 -0
- app/app/Http/Controllers/AuthController.php +33 -0
- app/app/Http/Controllers/AvisoController.php +252 -0
- app/app/Http/Controllers/CalificacionController.php +889 -0
- app/app/Http/Controllers/Controller.php +12 -0
- app/app/Http/Controllers/GrupoController.php +117 -0
- app/app/Http/Controllers/GrupoPrefectoController.php +129 -0
- app/app/Http/Controllers/HomeController.php +28 -0
- app/app/Http/Controllers/JustificanteController.php +253 -0
- app/app/Http/Controllers/JustificanteMaestroController.php +133 -0
- app/app/Http/Controllers/MaestroController.php +104 -0
- app/app/Http/Controllers/MateriaController.php +111 -0
- app/app/Http/Controllers/PeriodoController.php +93 -0
- app/app/Http/Controllers/PersonaController.php +125 -0
- app/app/Http/Controllers/ReporteController.php +251 -0
- app/app/Http/Controllers/RolController.php +98 -0
- app/app/Http/Controllers/SistemaController.php +50 -0
- app/app/Http/Controllers/TutorController.php +128 -0
- app/app/Http/Controllers/UsuarioController.php +129 -0
- app/app/Http/Kernel.php +69 -0
- app/app/Http/Middleware/Authenticate.php +17 -0
- app/app/Http/Middleware/EncryptCookies.php +17 -0
- app/app/Http/Middleware/PrefectoAccessMiddleware.php +102 -0
- app/app/Http/Middleware/PreventRequestsDuringMaintenance.php +17 -0
- app/app/Http/Middleware/RedirectIfAuthenticated.php +30 -0
- app/app/Http/Middleware/TrimStrings.php +19 -0
- app/app/Http/Middleware/TrustHosts.php +20 -0
- app/app/Http/Middleware/TrustProxies.php +28 -0
- app/app/Http/Middleware/ValidateSignature.php +22 -0
- app/app/Http/Middleware/VerifyCsrfToken.php +17 -0
- app/app/Models/Alumno.php +77 -0
- app/app/Models/Aviso.php +35 -0
- app/app/Models/Calificacion.php +26 -0
- app/app/Models/Grupo.php +46 -0
- app/app/Models/GrupoPrefecto.php +30 -0
- app/app/Models/Justificante.php +35 -0
- app/app/Models/JustificanteMaestro.php +34 -0
- app/app/Models/Maestro.php +20 -0
- app/app/Models/Materia.php +25 -0
app/.env.example
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
APP_NAME=Laravel
|
| 2 |
+
APP_ENV=local
|
| 3 |
+
APP_KEY=
|
| 4 |
+
APP_DEBUG=true
|
| 5 |
+
APP_URL=http://localhost
|
| 6 |
+
|
| 7 |
+
LOG_CHANNEL=stack
|
| 8 |
+
LOG_DEPRECATIONS_CHANNEL=null
|
| 9 |
+
LOG_LEVEL=debug
|
| 10 |
+
|
| 11 |
+
DB_CONNECTION=mysql
|
| 12 |
+
DB_HOST=$DB_HOST
|
| 13 |
+
DB_PORT=$DB_PORT
|
| 14 |
+
DB_DATABASE=$DB_DATABASE
|
| 15 |
+
DB_USERNAME=$DB_USERNAME
|
| 16 |
+
DB_PASSWORD=$DB_PASSWORD
|
| 17 |
+
|
| 18 |
+
BROADCAST_DRIVER=log
|
| 19 |
+
CACHE_DRIVER=file
|
| 20 |
+
FILESYSTEM_DISK=local
|
| 21 |
+
QUEUE_CONNECTION=sync
|
| 22 |
+
SESSION_DRIVER=file
|
| 23 |
+
SESSION_LIFETIME=120
|
| 24 |
+
|
| 25 |
+
MEMCACHED_HOST=127.0.0.1
|
| 26 |
+
|
| 27 |
+
REDIS_HOST=127.0.0.1
|
| 28 |
+
REDIS_PASSWORD=null
|
| 29 |
+
REDIS_PORT=6379
|
| 30 |
+
|
| 31 |
+
MAIL_MAILER=smtp
|
| 32 |
+
MAIL_HOST=mailpit
|
| 33 |
+
MAIL_PORT=1025
|
| 34 |
+
MAIL_USERNAME=null
|
| 35 |
+
MAIL_PASSWORD=null
|
| 36 |
+
MAIL_ENCRYPTION=null
|
| 37 |
+
MAIL_FROM_ADDRESS="hello@example.com"
|
| 38 |
+
MAIL_FROM_NAME="${APP_NAME}"
|
| 39 |
+
|
| 40 |
+
AWS_ACCESS_KEY_ID=
|
| 41 |
+
AWS_SECRET_ACCESS_KEY=
|
| 42 |
+
AWS_DEFAULT_REGION=us-east-1
|
| 43 |
+
AWS_BUCKET=
|
| 44 |
+
AWS_USE_PATH_STYLE_ENDPOINT=false
|
| 45 |
+
|
| 46 |
+
PUSHER_APP_ID=
|
| 47 |
+
PUSHER_APP_KEY=
|
| 48 |
+
PUSHER_APP_SECRET=
|
| 49 |
+
PUSHER_HOST=
|
| 50 |
+
PUSHER_PORT=443
|
| 51 |
+
PUSHER_SCHEME=https
|
| 52 |
+
PUSHER_APP_CLUSTER=mt1
|
| 53 |
+
|
| 54 |
+
VITE_APP_NAME="${APP_NAME}"
|
| 55 |
+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
| 56 |
+
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
| 57 |
+
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
| 58 |
+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
| 59 |
+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
app/.gitignore
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
composer.phar
|
| 2 |
+
/vendor/
|
| 3 |
+
#app/vendor
|
| 4 |
+
|
| 5 |
+
# composer.lock
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
node_modules/
|
| 9 |
+
**/node_modules/
|
| 10 |
+
app/node_modules
|
| 11 |
+
npm-debug.log
|
| 12 |
+
yarn-error.log
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
bootstrap/compiled.php
|
| 16 |
+
app/storage/
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
public/storage
|
| 20 |
+
public/hot
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
public_html/storage
|
| 24 |
+
public_html/hot
|
| 25 |
+
|
| 26 |
+
storage/*.key
|
| 27 |
+
.env
|
| 28 |
+
Homestead.yaml
|
| 29 |
+
Homestead.json
|
| 30 |
+
/.vagrant
|
| 31 |
+
.phpunit.result.cache
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
.vscode/*
|
| 35 |
+
!.vscode/settings.json
|
| 36 |
+
!.vscode/tasks.json
|
| 37 |
+
!.vscode/launch.json
|
| 38 |
+
!.vscode/extensions.json
|
| 39 |
+
!.vscode/*.code-snippets
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
.history/
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
*.vsix
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
.history
|
| 49 |
+
.ionide
|
app/app/Console/Kernel.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Console;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Console\Scheduling\Schedule;
|
| 6 |
+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
| 7 |
+
|
| 8 |
+
class Kernel extends ConsoleKernel
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Define the application's command schedule.
|
| 12 |
+
*/
|
| 13 |
+
protected function schedule(Schedule $schedule): void
|
| 14 |
+
{
|
| 15 |
+
// $schedule->command('inspire')->hourly();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Register the commands for the application.
|
| 20 |
+
*/
|
| 21 |
+
protected function commands(): void
|
| 22 |
+
{
|
| 23 |
+
$this->load(__DIR__.'/Commands');
|
| 24 |
+
|
| 25 |
+
require base_path('routes/console.php');
|
| 26 |
+
}
|
| 27 |
+
}
|
app/app/Exceptions/Handler.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Exceptions;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
| 6 |
+
use Throwable;
|
| 7 |
+
|
| 8 |
+
class Handler extends ExceptionHandler
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* The list of the inputs that are never flashed to the session on validation exceptions.
|
| 12 |
+
*
|
| 13 |
+
* @var array<int, string>
|
| 14 |
+
*/
|
| 15 |
+
protected $dontFlash = [
|
| 16 |
+
'current_password',
|
| 17 |
+
'password',
|
| 18 |
+
'password_confirmation',
|
| 19 |
+
];
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Register the exception handling callbacks for the application.
|
| 23 |
+
*/
|
| 24 |
+
public function register(): void
|
| 25 |
+
{
|
| 26 |
+
$this->reportable(function (Throwable $e) {
|
| 27 |
+
//
|
| 28 |
+
});
|
| 29 |
+
}
|
| 30 |
+
}
|
app/app/Http/Controllers/AdminController.php
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Request;
|
| 6 |
+
use App\Models\Role;
|
| 7 |
+
|
| 8 |
+
class AdminController extends Controller
|
| 9 |
+
{
|
| 10 |
+
public function index()
|
| 11 |
+
{
|
| 12 |
+
//$roles = Role::all();
|
| 13 |
+
return view('admin.index');
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
public function indexUsuarios()
|
| 17 |
+
{
|
| 18 |
+
return view('usuarios.index');
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function indexPersonas()
|
| 22 |
+
{
|
| 23 |
+
return view('personas.index');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
public function indexGrupos()
|
| 27 |
+
{
|
| 28 |
+
return view('grupos.index');
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public function indexTutores()
|
| 32 |
+
{
|
| 33 |
+
return view('tutores.index');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public function indexAlumnos()
|
| 37 |
+
{
|
| 38 |
+
return view('alumnos.index');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function indexMaterias()
|
| 42 |
+
{
|
| 43 |
+
return view('materias.index');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
public function indexCalificaciones()
|
| 47 |
+
{
|
| 48 |
+
return view('calificaciones.index');
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
public function indexPeriodos()
|
| 52 |
+
{
|
| 53 |
+
return view('periodos.index');
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
public function indexGrupos_Prefectos()
|
| 57 |
+
{
|
| 58 |
+
return view('grupos_prefectos.index');
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
public function indexReportes()
|
| 62 |
+
{
|
| 63 |
+
return view('repotes.index');
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
public function indexJustificantes()
|
| 67 |
+
{
|
| 68 |
+
return view('justificantes.index');
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
public function indexAvisos()
|
| 72 |
+
{
|
| 73 |
+
return view('avisos.index');
|
| 74 |
+
}
|
| 75 |
+
}
|
app/app/Http/Controllers/AlumnoController.php
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Alumno;
|
| 6 |
+
use App\Models\Persona;
|
| 7 |
+
use App\Models\Tutor;
|
| 8 |
+
use App\Models\Grupo;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use App\Models\Calificacion;
|
| 11 |
+
use App\Models\Materia;
|
| 12 |
+
use Illuminate\Http\Request;
|
| 13 |
+
use Illuminate\Support\Facades\Auth;
|
| 14 |
+
use Illuminate\Validation\Rule;
|
| 15 |
+
use Illuminate\Support\Facades\Storage;
|
| 16 |
+
use Illuminate\Support\Facades\Validator;
|
| 17 |
+
|
| 18 |
+
class AlumnoController extends Controller
|
| 19 |
+
{
|
| 20 |
+
/**
|
| 21 |
+
* Display a listing of the resource.
|
| 22 |
+
*/
|
| 23 |
+
public function index()
|
| 24 |
+
{
|
| 25 |
+
$usuario = Auth::user();
|
| 26 |
+
$persona = $usuario->persona;
|
| 27 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 28 |
+
|
| 29 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 30 |
+
$alumnos = Alumno::with('persona', 'grupo')->get();
|
| 31 |
+
return view('admin.alumnos.index', compact('alumnos'));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 35 |
+
->pluck('id_grupo')
|
| 36 |
+
->toArray();
|
| 37 |
+
|
| 38 |
+
//dd($gruposAsignados);
|
| 39 |
+
|
| 40 |
+
if (empty($gruposAsignados)) {
|
| 41 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)
|
| 45 |
+
->with('persona', 'grupo')
|
| 46 |
+
->get();
|
| 47 |
+
|
| 48 |
+
//dd($alumnos);
|
| 49 |
+
|
| 50 |
+
return view('admin.alumnos.index', compact('alumnos'));
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
public function porGradoYGrupo($grado, $grupo)
|
| 55 |
+
{
|
| 56 |
+
$usuario = Auth::user();
|
| 57 |
+
$persona = optional($usuario->persona);
|
| 58 |
+
$personaId = $persona->id_persona ?? null;
|
| 59 |
+
|
| 60 |
+
if (!$personaId) {
|
| 61 |
+
abort(403, 'No se encontró la información personal del usuario.');
|
| 62 |
+
}
|
| 63 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 64 |
+
|
| 65 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 66 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 67 |
+
->pluck('id_grupo')
|
| 68 |
+
->toArray();
|
| 69 |
+
|
| 70 |
+
$grupoEncontrado = Grupo::where('grado', $grado)
|
| 71 |
+
->where('grupo', $grupo)
|
| 72 |
+
->first();
|
| 73 |
+
|
| 74 |
+
if (!$grupoEncontrado || !in_array($grupoEncontrado->id_grupo, $gruposAsignados)) {
|
| 75 |
+
abort(403, 'Acceso denegado a este grupo.');
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
$grupoSeleccionado = Grupo::with('alumnos.persona', 'alumnos.tutor.persona')
|
| 80 |
+
->where('grado', $grado)
|
| 81 |
+
->where('grupo', $grupo)
|
| 82 |
+
->first();
|
| 83 |
+
|
| 84 |
+
return view('admin.alumnos.grupo', compact('grupoSeleccionado'));
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
public function promocionarAlumnos()
|
| 88 |
+
{
|
| 89 |
+
$alumnos = Alumno::all();
|
| 90 |
+
|
| 91 |
+
foreach ($alumnos as $alumno) {
|
| 92 |
+
|
| 93 |
+
$promedio = Calificacion::where('id_alumno', $alumno->id_alumno)->avg('calificacion');
|
| 94 |
+
$alumno->promedio_general = $promedio;
|
| 95 |
+
$alumno->save();
|
| 96 |
+
|
| 97 |
+
$grupoActual = Grupo::find($alumno->id_grupo);
|
| 98 |
+
|
| 99 |
+
if (!$grupoActual) {
|
| 100 |
+
continue;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
if ($grupoActual->grado == 3) {
|
| 104 |
+
|
| 105 |
+
$this->eliminarRegistrosAlumno($alumno);
|
| 106 |
+
} else {
|
| 107 |
+
|
| 108 |
+
if ($promedio >= 6.0) {
|
| 109 |
+
|
| 110 |
+
$this->eliminarCalificacionesGradoAnterior($alumno, $grupoActual->grado);
|
| 111 |
+
|
| 112 |
+
$nuevoGrupoId = $this->promocionarGrupo($alumno->id_grupo);
|
| 113 |
+
|
| 114 |
+
if ($nuevoGrupoId) {
|
| 115 |
+
$alumno->id_grupo = $nuevoGrupoId;
|
| 116 |
+
$alumno->save();
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
return redirect()->route('alumnos.index')
|
| 123 |
+
->with('mensaje', 'Promoción de alumnos realizada con éxito.')
|
| 124 |
+
->with('icono', 'success');
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
private function eliminarCalificacionesGradoAnterior($alumno, $gradoActual)
|
| 128 |
+
{
|
| 129 |
+
if ($gradoActual <= 1) {
|
| 130 |
+
return;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
$gradoAnterior = $gradoActual - 1;
|
| 134 |
+
|
| 135 |
+
$materias = Materia::where('grado', $gradoAnterior)->pluck('id_materia');
|
| 136 |
+
|
| 137 |
+
if ($materias->isNotEmpty()) {
|
| 138 |
+
Calificacion::where('id_alumno', $alumno->id_alumno)
|
| 139 |
+
->whereIn('id_materia', $materias)
|
| 140 |
+
->delete();
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
private function promocionarGrupo($idGrupo)
|
| 145 |
+
{
|
| 146 |
+
$grupoActual = Grupo::find($idGrupo);
|
| 147 |
+
|
| 148 |
+
if (!$grupoActual) {
|
| 149 |
+
return null;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
$siguienteGrupo = Grupo::where('grado', $grupoActual->grado + 1)
|
| 153 |
+
->where('grupo', $grupoActual->grupo)
|
| 154 |
+
->first();
|
| 155 |
+
|
| 156 |
+
return $siguienteGrupo ? $siguienteGrupo->id_grupo : null;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
private function eliminarRegistrosAlumno($alumno)
|
| 160 |
+
{
|
| 161 |
+
$idPersonaTutor = Tutor::where('id_tutor', $alumno->id_tutor)->value('persona_id');
|
| 162 |
+
|
| 163 |
+
Tutor::where('id_tutor', $alumno->id_tutor)->delete();
|
| 164 |
+
Calificacion::where('id_alumno', $alumno->id_alumno)->delete();
|
| 165 |
+
$alumno->delete();
|
| 166 |
+
|
| 167 |
+
if ($idPersonaTutor) {
|
| 168 |
+
Persona::where('id_persona', $idPersonaTutor)->delete();
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
Persona::where('id_persona', $alumno->persona_id)->delete();
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* Show the form for creating a new resource.
|
| 176 |
+
*/
|
| 177 |
+
public function create()
|
| 178 |
+
{
|
| 179 |
+
$personas = Persona::all();
|
| 180 |
+
$tutores = Tutor::all();
|
| 181 |
+
$grupos = Grupo::all();
|
| 182 |
+
return view('admin.alumnos.create', compact('personas', 'tutores', 'grupos'));
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Store a newly created resource in storage.
|
| 187 |
+
*/
|
| 188 |
+
public function store(Request $request)
|
| 189 |
+
{
|
| 190 |
+
//dd($request->all());
|
| 191 |
+
$request->validate([
|
| 192 |
+
'persona_id' => 'required|string|max:100',
|
| 193 |
+
'numero_control' => 'required|string|max:100|unique:alumnos,numero_control',
|
| 194 |
+
'id_tutor' => 'required|string|max:100',
|
| 195 |
+
'id_grupo' => 'required|string|max:100',
|
| 196 |
+
'curp' => 'required|string|max:100',
|
| 197 |
+
'image_path' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048'
|
| 198 |
+
]);
|
| 199 |
+
|
| 200 |
+
if ($request->hasFile('image')) {
|
| 201 |
+
$path = $request->file('image')->store('images', 'public');
|
| 202 |
+
|
| 203 |
+
//$grupo = Grupo::find($request->id_grupo);
|
| 204 |
+
|
| 205 |
+
$alumnos = new Alumno();
|
| 206 |
+
$alumnos->persona_id = $request->persona_id;
|
| 207 |
+
$alumnos->numero_control = $request->numero_control;
|
| 208 |
+
$alumnos->id_tutor = $request->id_tutor;
|
| 209 |
+
$alumnos->id_grupo = $request->id_grupo;
|
| 210 |
+
$alumnos->curp = $request->curp;
|
| 211 |
+
$alumnos->image_path = $path;
|
| 212 |
+
//dd($alumnos);
|
| 213 |
+
$alumnos->save();
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
return redirect()->route('alumnos.index')->with('mensaje', 'Se registro el alumno de la manera correcta')
|
| 217 |
+
->with('icono', 'success');
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Display the specified resource.
|
| 222 |
+
*/
|
| 223 |
+
public function show(string $id)
|
| 224 |
+
{
|
| 225 |
+
$alumnos = Alumno::with('persona', 'tutor', 'grupo')->findOrFail($id);
|
| 226 |
+
$persona_id = $alumnos->persona_id;
|
| 227 |
+
$id_tutor = $alumnos->id_tutor;
|
| 228 |
+
$id_grupo = $alumnos->id_grupo;
|
| 229 |
+
|
| 230 |
+
return view('admin.alumnos.show', [
|
| 231 |
+
'alumnos' => $alumnos
|
| 232 |
+
]);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
* Show the form for editing the specified resource.
|
| 237 |
+
*/
|
| 238 |
+
public function edit(string $id)
|
| 239 |
+
{
|
| 240 |
+
$alumnos = Alumno::findOrFail($id);
|
| 241 |
+
$personas = Persona::all();
|
| 242 |
+
$tutores = Tutor::all();
|
| 243 |
+
$grupos = Grupo::all();
|
| 244 |
+
return view('admin.alumnos.edit', compact('alumnos', 'personas', 'grupos', 'tutores'));
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* Update the specified resource in storage.
|
| 249 |
+
*/
|
| 250 |
+
public function update(Request $request, string $id)
|
| 251 |
+
{
|
| 252 |
+
$request->validate([
|
| 253 |
+
'persona_id' => 'required|string|max:50',
|
| 254 |
+
'numero_control' => ['required', 'string', 'max:50', Rule::unique('alumnos', 'numero_control')->ignore($id, 'id_alumno')],
|
| 255 |
+
'id_tutor' => 'required|string|max:50',
|
| 256 |
+
'id_grupo' => 'required|string|max:50',
|
| 257 |
+
'curp' => 'required|string|max:50',
|
| 258 |
+
'image' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048',
|
| 259 |
+
]);
|
| 260 |
+
|
| 261 |
+
$alumno = Alumno::findOrFail($id);
|
| 262 |
+
|
| 263 |
+
$grupo = Grupo::find($request->id_grupo);
|
| 264 |
+
|
| 265 |
+
$alumno->persona_id = $request->persona_id;
|
| 266 |
+
$alumno->numero_control = $request->numero_control;
|
| 267 |
+
$alumno->id_tutor = $request->id_tutor;
|
| 268 |
+
$alumno->id_grupo = $request->id_grupo;
|
| 269 |
+
$alumno->curp = $request->curp;
|
| 270 |
+
|
| 271 |
+
if ($request->hasFile('image')) {
|
| 272 |
+
|
| 273 |
+
if ($alumno->image_path && Storage::exists('public/' . $alumno->image_path)) {
|
| 274 |
+
Storage::delete('public/' . $alumno->image_path);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
$path = $request->file('image')->store('images', 'public');
|
| 278 |
+
$alumno->image_path = $path;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
$alumno->save();
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
if ($grupo) {
|
| 285 |
+
|
| 286 |
+
$gradoLimpio = str_replace('°', '', $grupo->grado);
|
| 287 |
+
|
| 288 |
+
return redirect()->route('alumnos.porGradoYGrupo', [
|
| 289 |
+
'grado' => $gradoLimpio,
|
| 290 |
+
'grupo' => $grupo->grupo
|
| 291 |
+
])->with('mensaje', 'Alumno actualizado con éxito.')
|
| 292 |
+
->with('icono', 'success');
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
return redirect()->route('alumnos.porGradoYGrupo')->with('mensaje', 'Alumno actualizado con éxito.')->with('icono', 'success');
|
| 296 |
+
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* Remove the specified resource from storage.
|
| 301 |
+
*/
|
| 302 |
+
public function destroy(string $id)
|
| 303 |
+
{
|
| 304 |
+
|
| 305 |
+
$alumno = Alumno::findOrFail($id);
|
| 306 |
+
|
| 307 |
+
$grupo = $alumno->grupo;
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
$alumno->delete();
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
if ($grupo) {
|
| 314 |
+
|
| 315 |
+
$gradoLimpio = str_replace('°', '', $grupo->grado);
|
| 316 |
+
|
| 317 |
+
return redirect()->route('alumnos.porGradoYGrupo', [
|
| 318 |
+
'grado' => $gradoLimpio,
|
| 319 |
+
'grupo' => $grupo->grupo
|
| 320 |
+
])->with('mensaje', 'Alumno eliminado con éxito.')
|
| 321 |
+
->with('icono', 'success');
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
return redirect()->route('alumnos.index')->with('mensaje', 'Alumno eliminado con éxito.')
|
| 325 |
+
->with('icono', 'success');
|
| 326 |
+
}
|
| 327 |
+
}
|
app/app/Http/Controllers/Auth/ConfirmPasswordController.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use App\Http\Controllers\Controller;
|
| 6 |
+
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
| 7 |
+
|
| 8 |
+
class ConfirmPasswordController extends Controller
|
| 9 |
+
{
|
| 10 |
+
/*
|
| 11 |
+
|--------------------------------------------------------------------------
|
| 12 |
+
| Confirm Password Controller
|
| 13 |
+
|--------------------------------------------------------------------------
|
| 14 |
+
|
|
| 15 |
+
| This controller is responsible for handling password confirmations and
|
| 16 |
+
| uses a simple trait to include the behavior. You're free to explore
|
| 17 |
+
| this trait and override any functions that require customization.
|
| 18 |
+
|
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
use ConfirmsPasswords;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Where to redirect users when the intended url fails.
|
| 25 |
+
*
|
| 26 |
+
* @var string
|
| 27 |
+
*/
|
| 28 |
+
protected $redirectTo = '/home';
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Create a new controller instance.
|
| 32 |
+
*
|
| 33 |
+
* @return void
|
| 34 |
+
*/
|
| 35 |
+
public function __construct()
|
| 36 |
+
{
|
| 37 |
+
$this->middleware('auth');
|
| 38 |
+
}
|
| 39 |
+
}
|
app/app/Http/Controllers/Auth/ForgotPasswordController.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use App\Http\Controllers\Controller;
|
| 6 |
+
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
| 7 |
+
|
| 8 |
+
class ForgotPasswordController extends Controller
|
| 9 |
+
{
|
| 10 |
+
/*
|
| 11 |
+
|--------------------------------------------------------------------------
|
| 12 |
+
| Password Reset Controller
|
| 13 |
+
|--------------------------------------------------------------------------
|
| 14 |
+
|
|
| 15 |
+
| This controller is responsible for handling password reset emails and
|
| 16 |
+
| includes a trait which assists in sending these notifications from
|
| 17 |
+
| your application to your users. Feel free to explore this trait.
|
| 18 |
+
|
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
use SendsPasswordResetEmails;
|
| 22 |
+
}
|
app/app/Http/Controllers/Auth/LoginController.php
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Request;
|
| 6 |
+
use Illuminate\Support\Facades\Auth;
|
| 7 |
+
use App\Http\Controllers\Controller;
|
| 8 |
+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
| 9 |
+
|
| 10 |
+
class LoginController extends Controller
|
| 11 |
+
{
|
| 12 |
+
/*
|
| 13 |
+
|--------------------------------------------------------------------------
|
| 14 |
+
| Login Controller
|
| 15 |
+
|--------------------------------------------------------------------------
|
| 16 |
+
|
|
| 17 |
+
| This controller handles authenticating users for the application and
|
| 18 |
+
| redirecting them to your home screen. The controller uses a trait
|
| 19 |
+
| to conveniently provide its functionality to your applications.
|
| 20 |
+
|
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
use AuthenticatesUsers;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Where to redirect users after login.
|
| 27 |
+
*
|
| 28 |
+
* @var string
|
| 29 |
+
*/
|
| 30 |
+
protected $redirectTo = '/';
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Create a new controller instance.
|
| 34 |
+
*
|
| 35 |
+
* @return void
|
| 36 |
+
*/
|
| 37 |
+
public function __construct()
|
| 38 |
+
{
|
| 39 |
+
$this->middleware('guest')->except('logout');
|
| 40 |
+
$this->middleware('auth')->only('logout');
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
public function logout(Request $request)
|
| 44 |
+
{
|
| 45 |
+
Auth::logout(); // Cerrar sesión
|
| 46 |
+
$request->session()->invalidate(); // Invalidar la sesión
|
| 47 |
+
$request->session()->regenerateToken(); // Regenerar el token de la sesión
|
| 48 |
+
|
| 49 |
+
return redirect()->route('login'); // Redirigir al login después de cerrar sesión
|
| 50 |
+
}
|
| 51 |
+
}
|
app/app/Http/Controllers/Auth/RegisterController.php
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use App\Http\Controllers\Controller;
|
| 6 |
+
use App\Models\Usuario;
|
| 7 |
+
use Illuminate\Foundation\Auth\RegistersUsers;
|
| 8 |
+
use Illuminate\Support\Facades\Hash;
|
| 9 |
+
use Illuminate\Support\Facades\Validator;
|
| 10 |
+
|
| 11 |
+
class RegisterController extends Controller
|
| 12 |
+
{
|
| 13 |
+
/*
|
| 14 |
+
|--------------------------------------------------------------------------
|
| 15 |
+
| Register Controller
|
| 16 |
+
|--------------------------------------------------------------------------
|
| 17 |
+
|
|
| 18 |
+
| This controller handles the registration of new users as well as their
|
| 19 |
+
| validation and creation. By default this controller uses a trait to
|
| 20 |
+
| provide this functionality without requiring any additional code.
|
| 21 |
+
|
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
use RegistersUsers;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Where to redirect users after registration.
|
| 28 |
+
*
|
| 29 |
+
* @var string
|
| 30 |
+
*/
|
| 31 |
+
protected $redirectTo = '/';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Create a new controller instance.
|
| 35 |
+
*
|
| 36 |
+
* @return void
|
| 37 |
+
*/
|
| 38 |
+
public function __construct()
|
| 39 |
+
{
|
| 40 |
+
$this->middleware('guest');
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Get a validator for an incoming registration request.
|
| 45 |
+
*
|
| 46 |
+
* @param array $data
|
| 47 |
+
* @return \Illuminate\Contracts\Validation\Validator
|
| 48 |
+
*/
|
| 49 |
+
protected function validator(array $data)
|
| 50 |
+
{
|
| 51 |
+
return Validator::make($data, [
|
| 52 |
+
'nombre_usuario' => ['required', 'string', 'max:255', 'unique:usuarios,nombre_usuario'],
|
| 53 |
+
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
| 54 |
+
'persona_id' => ['required', 'exists:personas,id_persona'],
|
| 55 |
+
'id_rol' => ['required', 'exists:roles,id_rol'],
|
| 56 |
+
]);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Create a new user instance after a valid registration.
|
| 61 |
+
*
|
| 62 |
+
* @param array $data
|
| 63 |
+
* @return \App\Models\Usuario
|
| 64 |
+
*/
|
| 65 |
+
protected function create(array $data)
|
| 66 |
+
{
|
| 67 |
+
return Usuario::create([
|
| 68 |
+
'nombre_usuario' => $data['nombre_usuario'],
|
| 69 |
+
'password' => Hash::make($data['password']),
|
| 70 |
+
'persona_id' => $data['persona_id'],
|
| 71 |
+
'id_rol' => $data['id_rol']
|
| 72 |
+
]);
|
| 73 |
+
}
|
| 74 |
+
}
|
app/app/Http/Controllers/Auth/ResetPasswordController.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use App\Http\Controllers\Controller;
|
| 6 |
+
use Illuminate\Foundation\Auth\ResetsPasswords;
|
| 7 |
+
|
| 8 |
+
class ResetPasswordController extends Controller
|
| 9 |
+
{
|
| 10 |
+
/*
|
| 11 |
+
|--------------------------------------------------------------------------
|
| 12 |
+
| Password Reset Controller
|
| 13 |
+
|--------------------------------------------------------------------------
|
| 14 |
+
|
|
| 15 |
+
| This controller is responsible for handling password reset requests
|
| 16 |
+
| and uses a simple trait to include this behavior. You're free to
|
| 17 |
+
| explore this trait and override any methods you wish to tweak.
|
| 18 |
+
|
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
use ResetsPasswords;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Where to redirect users after resetting their password.
|
| 25 |
+
*
|
| 26 |
+
* @var string
|
| 27 |
+
*/
|
| 28 |
+
protected $redirectTo = '/home';
|
| 29 |
+
}
|
app/app/Http/Controllers/Auth/VerificationController.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers\Auth;
|
| 4 |
+
|
| 5 |
+
use App\Http\Controllers\Controller;
|
| 6 |
+
use Illuminate\Foundation\Auth\VerifiesEmails;
|
| 7 |
+
|
| 8 |
+
class VerificationController extends Controller
|
| 9 |
+
{
|
| 10 |
+
/*
|
| 11 |
+
|--------------------------------------------------------------------------
|
| 12 |
+
| Email Verification Controller
|
| 13 |
+
|--------------------------------------------------------------------------
|
| 14 |
+
|
|
| 15 |
+
| This controller is responsible for handling email verification for any
|
| 16 |
+
| user that recently registered with the application. Emails may also
|
| 17 |
+
| be re-sent if the user didn't receive the original email message.
|
| 18 |
+
|
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
use VerifiesEmails;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Where to redirect users after verification.
|
| 25 |
+
*
|
| 26 |
+
* @var string
|
| 27 |
+
*/
|
| 28 |
+
protected $redirectTo = '/home';
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Create a new controller instance.
|
| 32 |
+
*
|
| 33 |
+
* @return void
|
| 34 |
+
*/
|
| 35 |
+
public function __construct()
|
| 36 |
+
{
|
| 37 |
+
$this->middleware('auth');
|
| 38 |
+
$this->middleware('signed')->only('verify');
|
| 39 |
+
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
| 40 |
+
}
|
| 41 |
+
}
|
app/app/Http/Controllers/AuthController.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Usuario;
|
| 6 |
+
use App\Http\Controllers\Controller;
|
| 7 |
+
use Illuminate\Http\Request;
|
| 8 |
+
use Illuminate\Support\Facades\Hash;
|
| 9 |
+
use Illuminate\Support\Facades\Auth;
|
| 10 |
+
|
| 11 |
+
class AuthController extends Controller
|
| 12 |
+
{
|
| 13 |
+
public function login(Request $request)
|
| 14 |
+
{
|
| 15 |
+
$request->validate([
|
| 16 |
+
'email' => 'required|email',
|
| 17 |
+
'password' => 'required|string',
|
| 18 |
+
]);
|
| 19 |
+
|
| 20 |
+
$usuario = Usuario::where('email', $request->email)->first();
|
| 21 |
+
|
| 22 |
+
if ($usuario && Hash::check($request->password, $usuario->password)) {
|
| 23 |
+
|
| 24 |
+
Auth::login($usuario);
|
| 25 |
+
return redirect()->intended('/');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return back()->withErrors([
|
| 29 |
+
'email' => 'Las credenciales no coinciden con nuestros registros.',
|
| 30 |
+
'password' => 'Las credenciales no coinciden con nuestros registros.',
|
| 31 |
+
]);
|
| 32 |
+
}
|
| 33 |
+
}
|
app/app/Http/Controllers/AvisoController.php
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Aviso;
|
| 6 |
+
use App\Models\Alumno;
|
| 7 |
+
use App\Models\Persona;
|
| 8 |
+
use App\Models\Periodo;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use Illuminate\Support\Facades\Auth;
|
| 11 |
+
use Barryvdh\DomPDF\Facade\Pdf;
|
| 12 |
+
use Illuminate\Http\Request;
|
| 13 |
+
|
| 14 |
+
class AvisoController extends Controller
|
| 15 |
+
{
|
| 16 |
+
/**
|
| 17 |
+
* Display a listing of the resource.
|
| 18 |
+
*/
|
| 19 |
+
public function index()
|
| 20 |
+
{
|
| 21 |
+
$usuario = Auth::user();
|
| 22 |
+
$persona = $usuario->persona;
|
| 23 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 24 |
+
|
| 25 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 26 |
+
$avisos = Aviso::with('alumno.persona', 'alumno.grupo')->get();
|
| 27 |
+
return view('admin.avisos.index', compact('avisos'));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 31 |
+
->pluck('id_grupo')
|
| 32 |
+
->toArray();
|
| 33 |
+
|
| 34 |
+
if (empty($gruposAsignados)) {
|
| 35 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$avisos = Aviso::whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 39 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 40 |
+
})->with('alumno.persona', 'alumno.grupo')->get();
|
| 41 |
+
|
| 42 |
+
return view('admin.avisos.index', compact('avisos'));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Show the form for creating a new resource.
|
| 47 |
+
*/
|
| 48 |
+
public function create()
|
| 49 |
+
{
|
| 50 |
+
$usuario = auth()->user();
|
| 51 |
+
$persona = $usuario->persona;
|
| 52 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 53 |
+
|
| 54 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 55 |
+
$alumnos = Alumno::with('persona')->get();
|
| 56 |
+
} else {
|
| 57 |
+
|
| 58 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 59 |
+
->pluck('id_grupo');
|
| 60 |
+
|
| 61 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
$personas = Persona::all();
|
| 65 |
+
return view('admin.avisos.create', compact('alumnos', 'personas'));
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Store a newly created resource in storage.
|
| 70 |
+
*/
|
| 71 |
+
public function store(Request $request)
|
| 72 |
+
{
|
| 73 |
+
$usuario = auth()->user();
|
| 74 |
+
$persona = $usuario->persona;
|
| 75 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 76 |
+
|
| 77 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 78 |
+
|
| 79 |
+
if ($rolNombre == 'Administrador') {
|
| 80 |
+
|
| 81 |
+
} else {
|
| 82 |
+
|
| 83 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 84 |
+
->pluck('id_grupo');
|
| 85 |
+
|
| 86 |
+
if (!$alumno || !$gruposAsignados->contains($alumno->id_grupo)) {
|
| 87 |
+
return redirect()->back()->with('error', 'No tienes permiso para justificar a este alumno.');
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
$request->validate([
|
| 92 |
+
'id_alumno' => 'required|string|max:50',
|
| 93 |
+
'persona_id' => 'required|string|max:50',
|
| 94 |
+
'mensaje' => 'required|string|max:250',
|
| 95 |
+
'fecha' => 'required|date|max:50',
|
| 96 |
+
]);
|
| 97 |
+
|
| 98 |
+
$avisos = new Aviso();
|
| 99 |
+
$avisos->id_alumno = $request->id_alumno;
|
| 100 |
+
$avisos->persona_id = $request->persona_id;
|
| 101 |
+
$avisos->mensaje = $request->mensaje;
|
| 102 |
+
$avisos->fecha = $request->fecha;
|
| 103 |
+
$avisos->save();
|
| 104 |
+
|
| 105 |
+
return redirect()->route('avisos.index')->with('mensaje', 'Aviso creado con éxito.')
|
| 106 |
+
->with('icono', 'success');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
public function pdf($id)
|
| 110 |
+
{
|
| 111 |
+
$usuario = Auth::user();
|
| 112 |
+
$persona = optional($usuario->persona);
|
| 113 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 114 |
+
|
| 115 |
+
$avisos = Aviso::with(['alumno.persona'])->findOrFail($id);
|
| 116 |
+
$alumno = $avisos->alumno;
|
| 117 |
+
|
| 118 |
+
if (!$alumno) {
|
| 119 |
+
return redirect()->back()->with('error', 'No se encontró el alumno asociado al aviso.');
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 123 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 124 |
+
->pluck('id_grupo')
|
| 125 |
+
->toArray();
|
| 126 |
+
|
| 127 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 128 |
+
abort(403, 'Acceso denegado: No puedes ver este PDF.');
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
$tutor = $alumno->tutor->persona ?? null;
|
| 133 |
+
$elaborador = $avisos->elaborador ?? null;
|
| 134 |
+
|
| 135 |
+
$periodo = Periodo::latest()->first();
|
| 136 |
+
|
| 137 |
+
$pdf = PDF::loadView('admin.avisos.pdf', compact('alumno', 'avisos', 'periodo', 'tutor', 'elaborador'));
|
| 138 |
+
|
| 139 |
+
return $pdf->stream();
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Display the specified resource.
|
| 144 |
+
*/
|
| 145 |
+
public function show(string $id)
|
| 146 |
+
{
|
| 147 |
+
$usuario = Auth::user();
|
| 148 |
+
$persona = $usuario->persona;
|
| 149 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 150 |
+
|
| 151 |
+
$avisos = Aviso::with('alumno.persona', 'creador')->findOrFail($id);
|
| 152 |
+
$alumno = $avisos->alumno;
|
| 153 |
+
$personaAlumno = $alumno->persona;
|
| 154 |
+
$creador = $avisos->creador;
|
| 155 |
+
$mensaje = $avisos->mensaje;
|
| 156 |
+
$fecha = $avisos->fecha;
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 160 |
+
return view('admin.avisos.show', compact('alumno', 'personaAlumno', 'creador', 'mensaje', 'fecha'));
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $usuario->persona_id)
|
| 164 |
+
->pluck('id_grupo')
|
| 165 |
+
->toArray();
|
| 166 |
+
|
| 167 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 168 |
+
abort(403, 'Acceso denegado. No puedes ver este aviso.');
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
return view('admin.avisos.show', compact('alumno', 'personaAlumno', 'creador', 'mensaje', 'fecha'));
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* Show the form for editing the specified resource.
|
| 176 |
+
*/
|
| 177 |
+
public function edit(string $id)
|
| 178 |
+
{
|
| 179 |
+
$usuario = Auth::user();
|
| 180 |
+
$persona = optional($usuario->persona);
|
| 181 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 182 |
+
|
| 183 |
+
$avisos = Aviso::with('alumno')->findOrFail($id);
|
| 184 |
+
$alumno = $avisos->alumno;
|
| 185 |
+
|
| 186 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 187 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 188 |
+
->pluck('id_grupo')
|
| 189 |
+
->toArray();
|
| 190 |
+
|
| 191 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 192 |
+
abort(403, 'Acceso denegado: No puedes editar este aviso.');
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
$alumnos = Alumno::all();
|
| 197 |
+
$personas = Persona::all();
|
| 198 |
+
|
| 199 |
+
return view('admin.avisos.edit', compact('alumnos', 'personas', 'avisos'));
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* Update the specified resource in storage.
|
| 204 |
+
*/
|
| 205 |
+
public function update(Request $request, string $id)
|
| 206 |
+
{
|
| 207 |
+
$usuario = Auth::user();
|
| 208 |
+
$persona = optional($usuario->persona);
|
| 209 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 210 |
+
|
| 211 |
+
$avisos = Aviso::findOrFail($id);
|
| 212 |
+
$alumno = $avisos->alumno;
|
| 213 |
+
|
| 214 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 215 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 216 |
+
->pluck('id_grupo')
|
| 217 |
+
->toArray();
|
| 218 |
+
|
| 219 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 220 |
+
abort(403, 'Acceso denegado: No puedes modificar este aviso.');
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
$request->validate([
|
| 225 |
+
'id_alumno' => 'nullable|string|max:50',
|
| 226 |
+
'persona_id' => 'nullable|string|max:50',
|
| 227 |
+
'mensaje' => 'required|string|max:255',
|
| 228 |
+
'fecha' => 'required|date|max:50'
|
| 229 |
+
]);
|
| 230 |
+
|
| 231 |
+
$avisos = Aviso::findOrFail($id);
|
| 232 |
+
$avisos->id_alumno = $request->id_alumno;
|
| 233 |
+
$avisos->persona_id = $request->persona_id;
|
| 234 |
+
$avisos->mensaje = $request->mensaje;
|
| 235 |
+
$avisos->fecha = $request->fecha;
|
| 236 |
+
$avisos->save();
|
| 237 |
+
|
| 238 |
+
return redirect()->route('avisos.index')->with('mensaje', 'Aviso actualizado con éxito.')
|
| 239 |
+
->with('icono', 'success');
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* Remove the specified resource from storage.
|
| 244 |
+
*/
|
| 245 |
+
public function destroy(string $id)
|
| 246 |
+
{
|
| 247 |
+
$avisos = Aviso::findOrFail($id);
|
| 248 |
+
$avisos->delete();
|
| 249 |
+
return redirect()->route('avisos.index')->with('mensaje', 'Aviso eliminado con éxito.')
|
| 250 |
+
->with('icono', 'success');
|
| 251 |
+
}
|
| 252 |
+
}
|
app/app/Http/Controllers/CalificacionController.php
ADDED
|
@@ -0,0 +1,889 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Calificacion;
|
| 6 |
+
use App\Models\Alumno;
|
| 7 |
+
use App\Models\Materia;
|
| 8 |
+
use App\Models\Grupo;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use Illuminate\Http\Request;
|
| 11 |
+
use Illuminate\Support\Facades\Auth;
|
| 12 |
+
|
| 13 |
+
class CalificacionController extends Controller
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* Display a listing of the resource.
|
| 17 |
+
*/
|
| 18 |
+
public function listarMaterias()
|
| 19 |
+
{
|
| 20 |
+
$materias = Materia::with('calificaciones.alumno.persona')->get();
|
| 21 |
+
return view('admin.calificaciones.materia', compact('materias'));
|
| 22 |
+
|
| 23 |
+
//$calificaciones = Calificacion::all();
|
| 24 |
+
}
|
| 25 |
+
public function listarGruposPorMateria($id_materia)
|
| 26 |
+
{
|
| 27 |
+
$materia = Materia::findOrFail($id_materia);
|
| 28 |
+
$grupos = Grupo::where('grado', $materia->grado)->get();
|
| 29 |
+
return view('admin.calificaciones.grupo', compact('materia', 'grupos'));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function listarAlumnosPorGrupo($id_materia, $id_grupo)
|
| 33 |
+
{
|
| 34 |
+
$materia = Materia::findOrFail($id_materia);
|
| 35 |
+
$grupo = Grupo::findOrFail($id_grupo);
|
| 36 |
+
$alumnos = Alumno::where('id_grupo', $id_grupo)->with('persona', 'calificaciones')->get();
|
| 37 |
+
|
| 38 |
+
return view('admin.calificaciones.alumno', compact('materia', 'grupo', 'alumnos'));
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
//$materias = Materia::where('grado', $grupos->grado)->first();
|
| 42 |
+
//$alumnos = Alumno::where('id_grupo', $id_grupo)->with('persona', 'calificaciones')->get();
|
| 43 |
+
|
| 44 |
+
//return view('admin.calificaciones.grupo', compact('materias', 'grupo', 'alumnos'));
|
| 45 |
+
}
|
| 46 |
+
//return view('admin.calificaciones.index', ['calificaciones'=>$calificaciones]);
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
public function primerTrimestre(Request $request)
|
| 50 |
+
{
|
| 51 |
+
$usuario = auth()->user();
|
| 52 |
+
$persona = $usuario->persona;
|
| 53 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 54 |
+
|
| 55 |
+
$grado = $request->input('grado');
|
| 56 |
+
$grupo = $request->input('grupo');
|
| 57 |
+
|
| 58 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 59 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 60 |
+
->where('trimestre', 1)
|
| 61 |
+
->when($grado, function ($query) use ($grado) {
|
| 62 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 63 |
+
$q->where('grado', $grado);
|
| 64 |
+
});
|
| 65 |
+
})
|
| 66 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 67 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 68 |
+
$q->where('grupo', $grupo);
|
| 69 |
+
});
|
| 70 |
+
})
|
| 71 |
+
->get();
|
| 72 |
+
|
| 73 |
+
return view('admin.calificaciones.primertrimestre', compact('calificaciones', 'grado', 'grupo'))
|
| 74 |
+
->with('trimestre', 'Primer Trimestre');
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 78 |
+
|
| 79 |
+
if ($asignaciones->isEmpty()) {
|
| 80 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo')->toArray();
|
| 84 |
+
|
| 85 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 86 |
+
->where('trimestre', 1)
|
| 87 |
+
->whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 88 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 89 |
+
})
|
| 90 |
+
->when($grado, function ($query) use ($grado) {
|
| 91 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 92 |
+
$q->where('grado', $grado);
|
| 93 |
+
});
|
| 94 |
+
})
|
| 95 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 96 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 97 |
+
$q->where('grupo', $grupo);
|
| 98 |
+
});
|
| 99 |
+
})
|
| 100 |
+
->get();
|
| 101 |
+
|
| 102 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 103 |
+
$materias = Materia::all();
|
| 104 |
+
|
| 105 |
+
return view('admin.calificaciones.primertrimestre', compact('calificaciones', 'alumnos', 'materias', 'grado', 'grupo'))
|
| 106 |
+
->with('trimestre', 'Primer Trimestre');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
public function segundoTrimestre(Request $request)
|
| 110 |
+
{
|
| 111 |
+
$usuario = auth()->user();
|
| 112 |
+
$persona = $usuario->persona;
|
| 113 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 114 |
+
|
| 115 |
+
$grado = $request->input('grado');
|
| 116 |
+
$grupo = $request->input('grupo');
|
| 117 |
+
|
| 118 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 119 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 120 |
+
->where('trimestre', 2)
|
| 121 |
+
->when($grado, function ($query) use ($grado) {
|
| 122 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 123 |
+
$q->where('grado', $grado);
|
| 124 |
+
});
|
| 125 |
+
})
|
| 126 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 127 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 128 |
+
$q->where('grupo', $grupo);
|
| 129 |
+
});
|
| 130 |
+
})
|
| 131 |
+
->get();
|
| 132 |
+
|
| 133 |
+
return view('admin.calificaciones.segundotrimestre', compact('calificaciones', 'grado', 'grupo'))
|
| 134 |
+
->with('trimestre', 'Primer Trimestre');
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 138 |
+
|
| 139 |
+
if ($asignaciones->isEmpty()) {
|
| 140 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo')->toArray();
|
| 144 |
+
|
| 145 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 146 |
+
->where('trimestre', 2)
|
| 147 |
+
->whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 148 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 149 |
+
})
|
| 150 |
+
->when($grado, function ($query) use ($grado) {
|
| 151 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 152 |
+
$q->where('grado', $grado);
|
| 153 |
+
});
|
| 154 |
+
})
|
| 155 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 156 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 157 |
+
$q->where('grupo', $grupo);
|
| 158 |
+
});
|
| 159 |
+
})
|
| 160 |
+
->get();
|
| 161 |
+
|
| 162 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 163 |
+
$materias = Materia::all();
|
| 164 |
+
|
| 165 |
+
return view('admin.calificaciones.segundotrimestre', compact('calificaciones', 'alumnos', 'materias', 'grado', 'grupo'))
|
| 166 |
+
->with('trimestre', 'Primer Trimestre');
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
public function tercerTrimestre(Request $request)
|
| 170 |
+
{
|
| 171 |
+
$usuario = auth()->user();
|
| 172 |
+
$persona = $usuario->persona;
|
| 173 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 174 |
+
|
| 175 |
+
$grado = $request->input('grado');
|
| 176 |
+
$grupo = $request->input('grupo');
|
| 177 |
+
|
| 178 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 179 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 180 |
+
->where('trimestre', 3)
|
| 181 |
+
->when($grado, function ($query) use ($grado) {
|
| 182 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 183 |
+
$q->where('grado', $grado);
|
| 184 |
+
});
|
| 185 |
+
})
|
| 186 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 187 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 188 |
+
$q->where('grupo', $grupo);
|
| 189 |
+
});
|
| 190 |
+
})
|
| 191 |
+
->get();
|
| 192 |
+
|
| 193 |
+
return view('admin.calificaciones.tercertrimestre', compact('calificaciones', 'grado', 'grupo'))
|
| 194 |
+
->with('trimestre', 'Primer Trimestre');
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 198 |
+
|
| 199 |
+
if ($asignaciones->isEmpty()) {
|
| 200 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo')->toArray();
|
| 204 |
+
|
| 205 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 206 |
+
->where('trimestre', 3)
|
| 207 |
+
->whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 208 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 209 |
+
})
|
| 210 |
+
->when($grado, function ($query) use ($grado) {
|
| 211 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 212 |
+
$q->where('grado', $grado);
|
| 213 |
+
});
|
| 214 |
+
})
|
| 215 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 216 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 217 |
+
$q->where('grupo', $grupo);
|
| 218 |
+
});
|
| 219 |
+
})
|
| 220 |
+
->get();
|
| 221 |
+
|
| 222 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 223 |
+
$materias = Materia::all();
|
| 224 |
+
|
| 225 |
+
return view('admin.calificaciones.tercertrimestre', compact('calificaciones', 'alumnos', 'materias', 'grado', 'grupo'))
|
| 226 |
+
->with('trimestre', 'Primer Trimestre');
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
public function cuartoTrimestre(Request $request)
|
| 230 |
+
{
|
| 231 |
+
$usuario = auth()->user();
|
| 232 |
+
$persona = $usuario->persona;
|
| 233 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 234 |
+
|
| 235 |
+
$grado = $request->input('grado');
|
| 236 |
+
$grupo = $request->input('grupo');
|
| 237 |
+
|
| 238 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 239 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 240 |
+
->where('trimestre', 4)
|
| 241 |
+
->when($grado, function ($query) use ($grado) {
|
| 242 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 243 |
+
$q->where('grado', $grado);
|
| 244 |
+
});
|
| 245 |
+
})
|
| 246 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 247 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 248 |
+
$q->where('grupo', $grupo);
|
| 249 |
+
});
|
| 250 |
+
})
|
| 251 |
+
->get();
|
| 252 |
+
|
| 253 |
+
return view('admin.calificaciones.cuartotrimestre', compact('calificaciones', 'grado', 'grupo'))
|
| 254 |
+
->with('trimestre', 'Primer Trimestre');
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 258 |
+
|
| 259 |
+
if ($asignaciones->isEmpty()) {
|
| 260 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo')->toArray();
|
| 264 |
+
|
| 265 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 266 |
+
->where('trimestre', 4)
|
| 267 |
+
->whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 268 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 269 |
+
})
|
| 270 |
+
->when($grado, function ($query) use ($grado) {
|
| 271 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 272 |
+
$q->where('grado', $grado);
|
| 273 |
+
});
|
| 274 |
+
})
|
| 275 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 276 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 277 |
+
$q->where('grupo', $grupo);
|
| 278 |
+
});
|
| 279 |
+
})
|
| 280 |
+
->get();
|
| 281 |
+
|
| 282 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 283 |
+
$materias = Materia::all();
|
| 284 |
+
|
| 285 |
+
return view('admin.calificaciones.cuartotrimestre', compact('calificaciones', 'alumnos', 'materias', 'grado', 'grupo'))
|
| 286 |
+
->with('trimestre', 'Primer Trimestre');
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
public function quintoTrimestre(Request $request)
|
| 290 |
+
{
|
| 291 |
+
$usuario = auth()->user();
|
| 292 |
+
$persona = $usuario->persona;
|
| 293 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 294 |
+
|
| 295 |
+
$grado = $request->input('grado');
|
| 296 |
+
$grupo = $request->input('grupo');
|
| 297 |
+
|
| 298 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 299 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 300 |
+
->where('trimestre', 5)
|
| 301 |
+
->when($grado, function ($query) use ($grado) {
|
| 302 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 303 |
+
$q->where('grado', $grado);
|
| 304 |
+
});
|
| 305 |
+
})
|
| 306 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 307 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 308 |
+
$q->where('grupo', $grupo);
|
| 309 |
+
});
|
| 310 |
+
})
|
| 311 |
+
->get();
|
| 312 |
+
|
| 313 |
+
return view('admin.calificaciones.quintotrimestre', compact('calificaciones', 'grado', 'grupo'))
|
| 314 |
+
->with('trimestre', 'Primer Trimestre');
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 318 |
+
|
| 319 |
+
if ($asignaciones->isEmpty()) {
|
| 320 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo')->toArray();
|
| 324 |
+
|
| 325 |
+
$calificaciones = Calificacion::with('alumno.persona', 'materia', 'alumno.grupo')
|
| 326 |
+
->where('trimestre', 5)
|
| 327 |
+
->whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 328 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 329 |
+
})
|
| 330 |
+
->when($grado, function ($query) use ($grado) {
|
| 331 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grado) {
|
| 332 |
+
$q->where('grado', $grado);
|
| 333 |
+
});
|
| 334 |
+
})
|
| 335 |
+
->when($grupo, function ($query) use ($grupo) {
|
| 336 |
+
return $query->whereHas('alumno.grupo', function ($q) use ($grupo) {
|
| 337 |
+
$q->where('grupo', $grupo);
|
| 338 |
+
});
|
| 339 |
+
})
|
| 340 |
+
->get();
|
| 341 |
+
|
| 342 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 343 |
+
$materias = Materia::all();
|
| 344 |
+
|
| 345 |
+
return view('admin.calificaciones.quintotrimestre', compact('calificaciones', 'alumnos', 'materias', 'grado', 'grupo'))
|
| 346 |
+
->with('trimestre', 'Primer Trimestre');
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* Show the form for creating a new resource.
|
| 351 |
+
*/
|
| 352 |
+
public function create()
|
| 353 |
+
{
|
| 354 |
+
$usuario = auth()->user();
|
| 355 |
+
$persona = $usuario->persona;
|
| 356 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 357 |
+
|
| 358 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 359 |
+
$alumnos = Alumno::all();
|
| 360 |
+
} else {
|
| 361 |
+
|
| 362 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 363 |
+
->pluck('id_grupo')->toArray();
|
| 364 |
+
|
| 365 |
+
if (empty($gruposAsignados)) {
|
| 366 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
$materias = Materia::all();
|
| 373 |
+
|
| 374 |
+
$trimestres = [1, 2, 3, 4, 5];
|
| 375 |
+
|
| 376 |
+
return view('admin.calificaciones.create', compact('alumnos', 'materias', 'trimestres'));
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
public function createprimertrimestre()
|
| 380 |
+
{
|
| 381 |
+
$usuario = auth()->user();
|
| 382 |
+
$persona = $usuario->persona;
|
| 383 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 384 |
+
|
| 385 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 386 |
+
$alumnos = Alumno::all();
|
| 387 |
+
} else {
|
| 388 |
+
|
| 389 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 390 |
+
->pluck('id_grupo')->toArray();
|
| 391 |
+
|
| 392 |
+
if (empty($gruposAsignados)) {
|
| 393 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
$materias = Materia::all();
|
| 400 |
+
return view('admin.calificaciones.createprimertrimestre', compact('alumnos', 'materias'));
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
public function createsegundotrimestre()
|
| 404 |
+
{
|
| 405 |
+
$usuario = auth()->user();
|
| 406 |
+
$persona = $usuario->persona;
|
| 407 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 408 |
+
|
| 409 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 410 |
+
$alumnos = Alumno::all();
|
| 411 |
+
} else {
|
| 412 |
+
|
| 413 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 414 |
+
->pluck('id_grupo')->toArray();
|
| 415 |
+
|
| 416 |
+
if (empty($gruposAsignados)) {
|
| 417 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
$materias = Materia::all();
|
| 424 |
+
return view('admin.calificaciones.createsegundotrimestre', compact('alumnos', 'materias'));
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
public function createtercertrimestre()
|
| 428 |
+
{
|
| 429 |
+
$usuario = auth()->user();
|
| 430 |
+
$persona = $usuario->persona;
|
| 431 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 432 |
+
|
| 433 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 434 |
+
$alumnos = Alumno::all();
|
| 435 |
+
} else {
|
| 436 |
+
|
| 437 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 438 |
+
->pluck('id_grupo')->toArray();
|
| 439 |
+
|
| 440 |
+
if (empty($gruposAsignados)) {
|
| 441 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
$materias = Materia::all();
|
| 448 |
+
return view('admin.calificaciones.createtercertrimestre', compact('alumnos', 'materias'));
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
public function createcuartotrimestre()
|
| 452 |
+
{
|
| 453 |
+
$usuario = auth()->user();
|
| 454 |
+
$persona = $usuario->persona;
|
| 455 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 456 |
+
|
| 457 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 458 |
+
$alumnos = Alumno::all();
|
| 459 |
+
} else {
|
| 460 |
+
|
| 461 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 462 |
+
->pluck('id_grupo')->toArray();
|
| 463 |
+
|
| 464 |
+
if (empty($gruposAsignados)) {
|
| 465 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
$materias = Materia::all();
|
| 472 |
+
return view('admin.calificaciones.createcuartotrimestre', compact('alumnos', 'materias'));
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
public function createquintotrimestre()
|
| 476 |
+
{
|
| 477 |
+
$usuario = auth()->user();
|
| 478 |
+
$persona = $usuario->persona;
|
| 479 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 480 |
+
|
| 481 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 482 |
+
$alumnos = Alumno::all();
|
| 483 |
+
} else {
|
| 484 |
+
|
| 485 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 486 |
+
->pluck('id_grupo')->toArray();
|
| 487 |
+
|
| 488 |
+
if (empty($gruposAsignados)) {
|
| 489 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
$materias = Materia::all();
|
| 496 |
+
return view('admin.calificaciones.createquintotrimestre', compact('alumnos', 'materias'));
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
/**
|
| 500 |
+
* Store a newly created resource in storage.
|
| 501 |
+
*/
|
| 502 |
+
|
| 503 |
+
public function store(Request $request)
|
| 504 |
+
{
|
| 505 |
+
$usuario = auth()->user();
|
| 506 |
+
$persona = $usuario->persona;
|
| 507 |
+
|
| 508 |
+
//$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 509 |
+
|
| 510 |
+
//$alumno = Alumno::findOrFail($request->id_alumno);
|
| 511 |
+
//if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 512 |
+
// return back()->with('error', 'No tienes permiso para registrar calificación para este alumno.');
|
| 513 |
+
//}
|
| 514 |
+
|
| 515 |
+
$request->validate([
|
| 516 |
+
'id_alumno' => 'required|string|max:100',
|
| 517 |
+
'id_materia' => 'required|string|max:100',
|
| 518 |
+
'calificacion' => 'required|string|max:100',
|
| 519 |
+
'trimestre' => 'required|string|in:1,2,3,4,5'
|
| 520 |
+
]);
|
| 521 |
+
|
| 522 |
+
$calificaciones = new Calificacion();
|
| 523 |
+
$calificaciones->id_alumno = $request->id_alumno;
|
| 524 |
+
$calificaciones->id_materia = $request->id_materia;
|
| 525 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 526 |
+
$calificaciones->trimestre = $request->trimestre;
|
| 527 |
+
$calificaciones->save();
|
| 528 |
+
|
| 529 |
+
return redirect()->route('calificaciones.index')->with('mensaje', 'Se registro la calificacion de la manera correcta')
|
| 530 |
+
->with('icono', 'success');
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
public function storesegundotrimestre(Request $request)
|
| 534 |
+
{
|
| 535 |
+
$usuario = auth()->user();
|
| 536 |
+
$persona = $usuario->persona;
|
| 537 |
+
|
| 538 |
+
//$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 539 |
+
|
| 540 |
+
//$alumno = Alumno::findOrFail($request->id_alumno);
|
| 541 |
+
//if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 542 |
+
// return back()->with('error', 'No tienes permiso para registrar calificación para este alumno.');
|
| 543 |
+
//}
|
| 544 |
+
|
| 545 |
+
$request->validate([
|
| 546 |
+
'id_alumno' => 'required|string|max:100',
|
| 547 |
+
'id_materia' => 'required|string|max:100',
|
| 548 |
+
'calificacion' => 'required|string|max:100',
|
| 549 |
+
'trimestre' => 'required|string|max:100'
|
| 550 |
+
]);
|
| 551 |
+
|
| 552 |
+
$calificaciones = new Calificacion();
|
| 553 |
+
$calificaciones->id_alumno = $request->id_alumno;
|
| 554 |
+
$calificaciones->id_materia = $request->id_materia;
|
| 555 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 556 |
+
$calificaciones->trimestre = $request->trimestre;
|
| 557 |
+
$calificaciones->save();
|
| 558 |
+
|
| 559 |
+
return redirect()->route('calificaciones.segundoTrimestre')->with('mensaje', 'Se registro la calificacion de la manera correcta')
|
| 560 |
+
->with('icono', 'success');
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
public function storetercertrimestre(Request $request)
|
| 564 |
+
{
|
| 565 |
+
$usuario = auth()->user();
|
| 566 |
+
$persona = $usuario->persona;
|
| 567 |
+
|
| 568 |
+
//$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 569 |
+
|
| 570 |
+
//$alumno = Alumno::findOrFail($request->id_alumno);
|
| 571 |
+
//if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 572 |
+
// return back()->with('error', 'No tienes permiso para registrar calificación para este alumno.');
|
| 573 |
+
//}
|
| 574 |
+
|
| 575 |
+
$request->validate([
|
| 576 |
+
'id_alumno' => 'required|string|max:100',
|
| 577 |
+
'id_materia' => 'required|string|max:100',
|
| 578 |
+
'calificacion' => 'required|string|max:100',
|
| 579 |
+
'trimestre' => 'required|string|max:100'
|
| 580 |
+
]);
|
| 581 |
+
|
| 582 |
+
$calificaciones = new Calificacion();
|
| 583 |
+
$calificaciones->id_alumno = $request->id_alumno;
|
| 584 |
+
$calificaciones->id_materia = $request->id_materia;
|
| 585 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 586 |
+
$calificaciones->trimestre = $request->trimestre;
|
| 587 |
+
$calificaciones->save();
|
| 588 |
+
|
| 589 |
+
return redirect()->route('calificaciones.tercerTrimestre')->with('mensaje', 'Se registro la calificacion de la manera correcta')
|
| 590 |
+
->with('icono', 'success');
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
public function storecuartotrimestre(Request $request)
|
| 594 |
+
{
|
| 595 |
+
$usuario = auth()->user();
|
| 596 |
+
$persona = $usuario->persona;
|
| 597 |
+
|
| 598 |
+
//$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 599 |
+
|
| 600 |
+
//$alumno = Alumno::findOrFail($request->id_alumno);
|
| 601 |
+
//if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 602 |
+
//return back()->with('error', 'No tienes permiso para registrar calificación para este alumno.');
|
| 603 |
+
//}
|
| 604 |
+
|
| 605 |
+
$request->validate([
|
| 606 |
+
'id_alumno' => 'required|string|max:100',
|
| 607 |
+
'id_materia' => 'required|string|max:100',
|
| 608 |
+
'calificacion' => 'required|string|max:100',
|
| 609 |
+
'trimestre' => 'required|string|max:100'
|
| 610 |
+
]);
|
| 611 |
+
|
| 612 |
+
$calificaciones = new Calificacion();
|
| 613 |
+
$calificaciones->id_alumno = $request->id_alumno;
|
| 614 |
+
$calificaciones->id_materia = $request->id_materia;
|
| 615 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 616 |
+
$calificaciones->trimestre = $request->trimestre;
|
| 617 |
+
$calificaciones->save();
|
| 618 |
+
|
| 619 |
+
return redirect()->route('calificaciones.cuartoTrimestre')->with('mensaje', 'Se registro la calificacion de la manera correcta')
|
| 620 |
+
->with('icono', 'success');
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
public function storequintotrimestre(Request $request)
|
| 624 |
+
{
|
| 625 |
+
$usuario = auth()->user();
|
| 626 |
+
$persona = $usuario->persona;
|
| 627 |
+
|
| 628 |
+
//$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 629 |
+
|
| 630 |
+
//$alumno = Alumno::findOrFail($request->id_alumno);
|
| 631 |
+
//if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 632 |
+
//return back()->with('error', 'No tienes permiso para registrar calificación para este alumno.');
|
| 633 |
+
//}
|
| 634 |
+
|
| 635 |
+
$request->validate([
|
| 636 |
+
'id_alumno' => 'required|string|max:100',
|
| 637 |
+
'id_materia' => 'required|string|max:100',
|
| 638 |
+
'calificacion' => 'required|string|max:100',
|
| 639 |
+
'trimestre' => 'required|string|max:100'
|
| 640 |
+
]);
|
| 641 |
+
|
| 642 |
+
$calificaciones = new Calificacion();
|
| 643 |
+
$calificaciones->id_alumno = $request->id_alumno;
|
| 644 |
+
$calificaciones->id_materia = $request->id_materia;
|
| 645 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 646 |
+
$calificaciones->trimestre = $request->trimestre;
|
| 647 |
+
$calificaciones->save();
|
| 648 |
+
|
| 649 |
+
return redirect()->route('calificaciones.quintoTrimestre')->with('mensaje', 'Se registro la calificacion de la manera correcta')
|
| 650 |
+
->with('icono', 'success');
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
/**
|
| 654 |
+
* Display the specified resource.
|
| 655 |
+
*/
|
| 656 |
+
public function show(string $id)
|
| 657 |
+
{
|
| 658 |
+
$calificaciones = Calificacion::with('alumno', 'materia')->findOrFail($id);
|
| 659 |
+
$id_alumno = $calificaciones->id_alumno;
|
| 660 |
+
$id_materia = $calificaciones->id_materia;
|
| 661 |
+
$calificacion = $calificaciones->calificacion;
|
| 662 |
+
|
| 663 |
+
return view('admin.calificaciones.show', compact('calificaciones'));
|
| 664 |
+
|
| 665 |
+
return view('admin.calificaciones.show', [
|
| 666 |
+
'id_alumno' => $id_alumno,
|
| 667 |
+
'id_materia' => $id_materia,
|
| 668 |
+
'calificacion' => $calificacion
|
| 669 |
+
]);
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
public function showsegundotrimestre(string $id)
|
| 673 |
+
{
|
| 674 |
+
$calificaciones = Calificacion::with('alumno', 'materia')->findOrFail($id);
|
| 675 |
+
$id_alumno = $calificaciones->id_alumno;
|
| 676 |
+
$id_materia = $calificaciones->id_materia;
|
| 677 |
+
$calificacion = $calificaciones->calificacion;
|
| 678 |
+
|
| 679 |
+
return view('admin.calificaciones.showsegundotrimestre', compact('calificaciones'));
|
| 680 |
+
|
| 681 |
+
return view('admin.calificaciones.show', [
|
| 682 |
+
'id_alumno' => $id_alumno,
|
| 683 |
+
'id_materia' => $id_materia,
|
| 684 |
+
'calificacion' => $calificacion
|
| 685 |
+
]);
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
public function showtercertrimestre(string $id)
|
| 689 |
+
{
|
| 690 |
+
$calificaciones = Calificacion::with('alumno', 'materia')->findOrFail($id);
|
| 691 |
+
$id_alumno = $calificaciones->id_alumno;
|
| 692 |
+
$id_materia = $calificaciones->id_materia;
|
| 693 |
+
$calificacion = $calificaciones->calificacion;
|
| 694 |
+
|
| 695 |
+
return view('admin.calificaciones.showtercertrimestre', compact('calificaciones'));
|
| 696 |
+
|
| 697 |
+
return view('admin.calificaciones.show', [
|
| 698 |
+
'id_alumno' => $id_alumno,
|
| 699 |
+
'id_materia' => $id_materia,
|
| 700 |
+
'calificacion' => $calificacion
|
| 701 |
+
]);
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
public function showcuartotrimestre(string $id)
|
| 705 |
+
{
|
| 706 |
+
$calificaciones = Calificacion::with('alumno', 'materia')->findOrFail($id);
|
| 707 |
+
$id_alumno = $calificaciones->id_alumno;
|
| 708 |
+
$id_materia = $calificaciones->id_materia;
|
| 709 |
+
$calificacion = $calificaciones->calificacion;
|
| 710 |
+
|
| 711 |
+
return view('admin.calificaciones.showcuartotrimestre', compact('calificaciones'));
|
| 712 |
+
|
| 713 |
+
return view('admin.calificaciones.show', [
|
| 714 |
+
'id_alumno' => $id_alumno,
|
| 715 |
+
'id_materia' => $id_materia,
|
| 716 |
+
'calificacion' => $calificacion
|
| 717 |
+
]);
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
public function showquintotrimestre(string $id)
|
| 721 |
+
{
|
| 722 |
+
$calificaciones = Calificacion::with('alumno', 'materia')->findOrFail($id);
|
| 723 |
+
$id_alumno = $calificaciones->id_alumno;
|
| 724 |
+
$id_materia = $calificaciones->id_materia;
|
| 725 |
+
$calificacion = $calificaciones->calificacion;
|
| 726 |
+
|
| 727 |
+
return view('admin.calificaciones.showquintotrimestre', compact('calificaciones'));
|
| 728 |
+
|
| 729 |
+
return view('admin.calificaciones.show', [
|
| 730 |
+
'id_alumno' => $id_alumno,
|
| 731 |
+
'id_materia' => $id_materia,
|
| 732 |
+
'calificacion' => $calificacion
|
| 733 |
+
]);
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
/**
|
| 737 |
+
* Show the form for editing the specified resource.
|
| 738 |
+
*/
|
| 739 |
+
public function edit(string $id)
|
| 740 |
+
{
|
| 741 |
+
$calificacion = Calificacion::where('id_alumno', $id)->get();;
|
| 742 |
+
$alumnos = Alumno::all();
|
| 743 |
+
$materias = Materia::all();
|
| 744 |
+
$trimestres = [1, 2, 3, 4, 5];
|
| 745 |
+
$alumno = Alumno::findOrFail($id);
|
| 746 |
+
return view('admin.calificaciones.edit', compact('calificacion', 'alumnos', 'materias', 'trimestres', 'alumno'));
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
/**
|
| 750 |
+
* Update the specified resource in storage.
|
| 751 |
+
*/
|
| 752 |
+
public function update(Request $request, string $id)
|
| 753 |
+
{
|
| 754 |
+
//dd($request->all());
|
| 755 |
+
$request->validate([
|
| 756 |
+
'id_alumno' => 'nullable|string|max:50',
|
| 757 |
+
'id_materia' => 'required|string|max:50',
|
| 758 |
+
'trimestre' => 'required|integer|min:1|max:5',
|
| 759 |
+
'calificacion' => 'nullable|numeric',
|
| 760 |
+
]);
|
| 761 |
+
|
| 762 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 763 |
+
// $calificaciones->id_alumno = $request->id_alumno;
|
| 764 |
+
// $calificaciones->id_materia = $request->id_materia;
|
| 765 |
+
$calificaciones->calificacion = $request->calificacion;
|
| 766 |
+
$calificaciones->save();
|
| 767 |
+
|
| 768 |
+
return redirect()->route('calificaciones.index')->with('mensaje', 'Calificaion actualizada con éxito.')
|
| 769 |
+
->with('icono', 'success');
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
|
| 773 |
+
public function listarAlumnos()
|
| 774 |
+
{
|
| 775 |
+
$usuario = auth()->user();
|
| 776 |
+
$persona = $usuario->persona;
|
| 777 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 778 |
+
|
| 779 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 780 |
+
$alumnos = Alumno::with('persona')->get();
|
| 781 |
+
|
| 782 |
+
return view('admin.calificaciones.listadoalumnos', compact('alumnos'));
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 786 |
+
|
| 787 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->with('persona')->get();
|
| 788 |
+
|
| 789 |
+
return view('admin.calificaciones.listadoalumnos', compact('alumnos'));
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
public function calificacionesFinales($id_alumno)
|
| 793 |
+
{
|
| 794 |
+
$usuario = auth()->user();
|
| 795 |
+
$persona = $usuario->persona;
|
| 796 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 797 |
+
|
| 798 |
+
$alumno = Alumno::with('persona')->findOrFail($id_alumno);
|
| 799 |
+
|
| 800 |
+
if ($rolNombre == 'Prefecto') {
|
| 801 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 802 |
+
|
| 803 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 804 |
+
return redirect()->route('calificaciones.listadoalumnos')->with('error', 'No tienes permiso para ver estas calificaciones.');
|
| 805 |
+
}
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
$calificacionGeneral = null;
|
| 809 |
+
|
| 810 |
+
$calificacionesFinales = Calificacion::select('id_materia')
|
| 811 |
+
->where('id_alumno', $id_alumno)
|
| 812 |
+
->selectRaw('AVG(calificacion) as promedio')
|
| 813 |
+
->groupBy('id_materia')
|
| 814 |
+
->with('materia')
|
| 815 |
+
->get();
|
| 816 |
+
|
| 817 |
+
if ($calificacionesFinales->isNotEmpty()) {
|
| 818 |
+
$calificacionGeneral = $calificacionesFinales->avg('promedio');
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
return view('admin.calificaciones.final', compact('alumno', 'calificacionesFinales', 'calificacionGeneral'));
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
public function calificacionesPorGrado($grado, $seccion)
|
| 825 |
+
{
|
| 826 |
+
$grupo = Grupo::where('grado', $grado)->where('grupo', $seccion)->first();
|
| 827 |
+
|
| 828 |
+
if (!$grupo) {
|
| 829 |
+
return response()->json(['error' => 'Grupo no encontrado'], 404);
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
$calificaciones = Calificacion::whereHas('alumno', function ($query) use ($grupo) {
|
| 833 |
+
$query->where('id_grupo', $grupo->id_grupo);
|
| 834 |
+
})
|
| 835 |
+
->with(['alumno.persona', 'materia', 'trimestre'])
|
| 836 |
+
->get();
|
| 837 |
+
|
| 838 |
+
return view('calificaciones.index', compact('calificaciones', 'grado', 'seccion'));
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
/**
|
| 842 |
+
* Remove the specified resource from storage.
|
| 843 |
+
*/
|
| 844 |
+
public function destroyprimertrimestre(string $id)
|
| 845 |
+
{
|
| 846 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 847 |
+
$calificaciones->delete();
|
| 848 |
+
|
| 849 |
+
return redirect()->route('calificaciones.index')->with('mensaje', 'Calificacion eliminada con éxito.')
|
| 850 |
+
->with('icono', 'success');
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
public function destroysegundotrimestre(string $id)
|
| 854 |
+
{
|
| 855 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 856 |
+
$calificaciones->delete();
|
| 857 |
+
|
| 858 |
+
return redirect()->route('calificaciones.segundoTrimestre')->with('mensaje', 'Calificacion eliminada con éxito.')
|
| 859 |
+
->with('icono', 'success');
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
+
public function destroytercertrimestre(string $id)
|
| 863 |
+
{
|
| 864 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 865 |
+
$calificaciones->delete();
|
| 866 |
+
|
| 867 |
+
return redirect()->route('calificaciones.tercerTrimestre')->with('mensaje', 'Calificacion eliminada con éxito.')
|
| 868 |
+
->with('icono', 'success');
|
| 869 |
+
}
|
| 870 |
+
|
| 871 |
+
public function destroycuartotrimestre(string $id)
|
| 872 |
+
{
|
| 873 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 874 |
+
$calificaciones->delete();
|
| 875 |
+
|
| 876 |
+
return redirect()->route('calificaciones.cuartoTrimestre')->with('mensaje', 'Calificacion eliminada con éxito.')
|
| 877 |
+
->with('icono', 'success');
|
| 878 |
+
}
|
| 879 |
+
|
| 880 |
+
public function destroyquintotrimestre(string $id)
|
| 881 |
+
{
|
| 882 |
+
$calificaciones = Calificacion::findOrFail($id);
|
| 883 |
+
$calificaciones->delete();
|
| 884 |
+
|
| 885 |
+
return redirect()->route('calificaciones.quintoTrimestre')->with('mensaje', 'Calificacion eliminada con éxito.')
|
| 886 |
+
->with('icono', 'success');
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
}
|
app/app/Http/Controllers/Controller.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
| 6 |
+
use Illuminate\Foundation\Validation\ValidatesRequests;
|
| 7 |
+
use Illuminate\Routing\Controller as BaseController;
|
| 8 |
+
|
| 9 |
+
class Controller extends BaseController
|
| 10 |
+
{
|
| 11 |
+
use AuthorizesRequests, ValidatesRequests;
|
| 12 |
+
}
|
app/app/Http/Controllers/GrupoController.php
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Grupo;
|
| 6 |
+
use Illuminate\Support\Facades\Auth;
|
| 7 |
+
use Illuminate\Validation\Rule;
|
| 8 |
+
use Illuminate\Http\Request;
|
| 9 |
+
|
| 10 |
+
class GrupoController extends Controller
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Display a listing of the resource.
|
| 14 |
+
*/
|
| 15 |
+
public function index()
|
| 16 |
+
{
|
| 17 |
+
$usuario = auth()->user();
|
| 18 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 19 |
+
|
| 20 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 21 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
$grupos = Grupo::all();
|
| 25 |
+
return view('admin.grupos.index', ['grupos'=>$grupos]);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Show the form for creating a new resource.
|
| 30 |
+
*/
|
| 31 |
+
public function create()
|
| 32 |
+
{
|
| 33 |
+
return view('admin.grupos.create');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Store a newly created resource in storage.
|
| 38 |
+
*/
|
| 39 |
+
public function store(Request $request)
|
| 40 |
+
{
|
| 41 |
+
//dd($request->all());
|
| 42 |
+
$request->validate([
|
| 43 |
+
'grupo' => 'required|string|max:5',
|
| 44 |
+
'grado' => 'required|string|max:5'
|
| 45 |
+
]);
|
| 46 |
+
|
| 47 |
+
$existeGrupo = Grupo::where('grupo', $request->grupo)
|
| 48 |
+
->where('grado', $request->grado)
|
| 49 |
+
->exists();
|
| 50 |
+
|
| 51 |
+
if ($existeGrupo) {
|
| 52 |
+
return redirect()->back()->with([
|
| 53 |
+
'mensaje' => 'El grado y grupo ya se encuentran registrados.',
|
| 54 |
+
'icono' => 'error'
|
| 55 |
+
]);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
$grupo = new Grupo();
|
| 59 |
+
$grupo->grupo = $request->grupo;
|
| 60 |
+
$grupo->grado = $request->grado;
|
| 61 |
+
$grupo->save();
|
| 62 |
+
|
| 63 |
+
return redirect()->route('grupos.index')->with([
|
| 64 |
+
'mensaje' => 'Grupo creado con éxito.',
|
| 65 |
+
'icono' => 'success'
|
| 66 |
+
]);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Display the specified resource.
|
| 71 |
+
*/
|
| 72 |
+
public function show(string $id)
|
| 73 |
+
{
|
| 74 |
+
$grupos = Grupo::findOrFail($id);
|
| 75 |
+
return view('admin.grupos.show', ['grupos'=>$grupos]);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Show the form for editing the specified resource.
|
| 80 |
+
*/
|
| 81 |
+
public function edit(string $id)
|
| 82 |
+
{
|
| 83 |
+
$grupos = Grupo::with(['alumnos', 'gruposprefecto'])->findOrFail($id);
|
| 84 |
+
return view('admin.grupos.edit', compact('grupos'));
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Update the specified resource in storage.
|
| 89 |
+
*/
|
| 90 |
+
public function update(Request $request, string $id)
|
| 91 |
+
{
|
| 92 |
+
$request->validate([
|
| 93 |
+
'grado' => ['required', 'string', 'max:20', Rule::unique('grupos', 'grado')->ignore($id, 'id_grupo')],
|
| 94 |
+
'grupo' => ['required', 'string', 'max:20', Rule::unique('grupos', 'grupo')->ignore($id, 'id_grupo')],
|
| 95 |
+
]);
|
| 96 |
+
|
| 97 |
+
$grupos = Grupo::findOrFail($id);
|
| 98 |
+
$grupos->grado = $request->grado;
|
| 99 |
+
$grupos->grupo = $request->grupo;
|
| 100 |
+
$grupos->save();
|
| 101 |
+
|
| 102 |
+
return redirect()->route('grupos.index')->with('mensaje', 'Grupo actualizado con éxito.')
|
| 103 |
+
->with('icono', 'success');
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Remove the specified resource from storage.
|
| 108 |
+
*/
|
| 109 |
+
public function destroy(string $id)
|
| 110 |
+
{
|
| 111 |
+
$grupos = Grupo::findOrFail($id);
|
| 112 |
+
$grupos->delete();
|
| 113 |
+
|
| 114 |
+
return redirect()->route('grupos.index')->with('mensaje', 'Grupo eliminado con éxito.')
|
| 115 |
+
->with('icono', 'success');
|
| 116 |
+
}
|
| 117 |
+
}
|
app/app/Http/Controllers/GrupoPrefectoController.php
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\GrupoPrefecto;
|
| 6 |
+
use App\Models\Grupo;
|
| 7 |
+
use App\Models\Periodo;
|
| 8 |
+
use App\Models\Persona;
|
| 9 |
+
use Illuminate\Support\Facades\Auth;
|
| 10 |
+
use Illuminate\Validation\Rule;
|
| 11 |
+
use Illuminate\Http\Request;
|
| 12 |
+
|
| 13 |
+
class GrupoPrefectoController extends Controller
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* Display a listing of the resource.
|
| 17 |
+
*/
|
| 18 |
+
public function index()
|
| 19 |
+
{
|
| 20 |
+
$usuario = auth()->user();
|
| 21 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 22 |
+
|
| 23 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 24 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
$grupos_prefectos = GrupoPrefecto::all();
|
| 28 |
+
return view('admin.grupos_prefectos.index', ['grupos_prefectos'=>$grupos_prefectos]);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Show the form for creating a new resource.
|
| 33 |
+
*/
|
| 34 |
+
public function create()
|
| 35 |
+
{
|
| 36 |
+
$grupos_prefectos = GrupoPrefecto::all();
|
| 37 |
+
$grupos = Grupo::all();
|
| 38 |
+
$periodos = Periodo::all();
|
| 39 |
+
$personas = Persona::all();
|
| 40 |
+
return view('admin.grupos_prefectos.create', compact('personas', 'grupos', 'periodos'));
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Store a newly created resource in storage.
|
| 45 |
+
*/
|
| 46 |
+
public function store(Request $request)
|
| 47 |
+
{
|
| 48 |
+
$request->validate([
|
| 49 |
+
'id_grupo' => 'required|string|max:50|unique:grupos_prefectos,id_grupo',
|
| 50 |
+
'id_periodo' => 'required|string|max:50',
|
| 51 |
+
'persona_id' => 'required|string|max:50'
|
| 52 |
+
]);
|
| 53 |
+
|
| 54 |
+
$grupos_prefectos = new GrupoPrefecto();
|
| 55 |
+
$grupos_prefectos->id_grupo = $request->id_grupo;
|
| 56 |
+
$grupos_prefectos->id_periodo = $request->id_periodo;
|
| 57 |
+
$grupos_prefectos->persona_id = $request->persona_id;
|
| 58 |
+
$grupos_prefectos->save();
|
| 59 |
+
|
| 60 |
+
return redirect()->route('grupos_prefectos.index')->with('mensaje', 'Grupo prefecto creado con éxito.')
|
| 61 |
+
->with('icono', 'success');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Display the specified resource.
|
| 66 |
+
*/
|
| 67 |
+
public function show(string $id)
|
| 68 |
+
{
|
| 69 |
+
$grupos_prefectos = GrupoPrefecto::with('persona', 'grupo', 'periodo')->findOrFail($id);
|
| 70 |
+
$nombre_persona = "{$grupos_prefectos->persona->nombre} {$grupos_prefectos->persona->apellido_paterno} {$grupos_prefectos->persona->apellido_materno}";
|
| 71 |
+
$nombre_grupo = $grupos_prefectos->grupo->grupo;
|
| 72 |
+
$nombre_periodo = $grupos_prefectos->periodo->nombre_periodo;
|
| 73 |
+
|
| 74 |
+
$nombre_grupo = $grupos_prefectos->grupo->grado . " " . $grupos_prefectos->grupo->grupo;
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
return view('admin.grupos_prefectos.show', [
|
| 78 |
+
'nombre_persona' => $nombre_persona,
|
| 79 |
+
'nombre_grupo' => $nombre_grupo,
|
| 80 |
+
'nombre_periodo' => $nombre_periodo
|
| 81 |
+
]);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Show the form for editing the specified resource.
|
| 86 |
+
*/
|
| 87 |
+
public function edit(string $id)
|
| 88 |
+
{
|
| 89 |
+
$grupos_prefectos = GrupoPrefecto::findOrFail($id);
|
| 90 |
+
$grupos = Grupo::all();
|
| 91 |
+
$personas = Persona::all();
|
| 92 |
+
$periodos = Periodo::all();
|
| 93 |
+
return view('admin.grupos_prefectos.edit', compact('grupos_prefectos', 'grupos', 'personas', 'periodos'));
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Update the specified resource in storage.
|
| 98 |
+
*/
|
| 99 |
+
public function update(Request $request, string $id)
|
| 100 |
+
{
|
| 101 |
+
//dd($request->all());
|
| 102 |
+
$request->validate([
|
| 103 |
+
'persona_id' => 'required|string|max:50',
|
| 104 |
+
'id_grupo' => ['required', 'string', 'max:10', Rule::unique('grupos_prefectos', 'id_grupo')->ignore($id, 'id_grupo_prefecto')],
|
| 105 |
+
'id_periodo' => 'required|string|max:50'
|
| 106 |
+
]);
|
| 107 |
+
|
| 108 |
+
$grupos_prefectos = GrupoPrefecto::findOrFail($id);
|
| 109 |
+
$grupos_prefectos->persona_id = $request->persona_id;
|
| 110 |
+
$grupos_prefectos->id_grupo = $request->id_grupo;
|
| 111 |
+
$grupos_prefectos->id_periodo = $request->id_periodo;
|
| 112 |
+
$grupos_prefectos->save();
|
| 113 |
+
|
| 114 |
+
return redirect()->route('grupos_prefectos.index')->with('mensaje', 'Grupo prefecto actualizado con éxito.')
|
| 115 |
+
->with('icono', 'success');
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Remove the specified resource from storage.
|
| 120 |
+
*/
|
| 121 |
+
public function destroy(string $id)
|
| 122 |
+
{
|
| 123 |
+
$grupos_prefectos = GrupoPrefecto::findOrFail($id);
|
| 124 |
+
$grupos_prefectos->delete();
|
| 125 |
+
|
| 126 |
+
return redirect()->route('grupos_prefectos.index')->with('mensaje', 'Grupo prefecto eliminado con éxito.')
|
| 127 |
+
->with('icono', 'success');
|
| 128 |
+
}
|
| 129 |
+
}
|
app/app/Http/Controllers/HomeController.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Request;
|
| 6 |
+
|
| 7 |
+
class HomeController extends Controller
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* Create a new controller instance.
|
| 11 |
+
*
|
| 12 |
+
* @return void
|
| 13 |
+
*/
|
| 14 |
+
public function __construct()
|
| 15 |
+
{
|
| 16 |
+
$this->middleware('auth');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Show the application dashboard.
|
| 21 |
+
*
|
| 22 |
+
* @return \Illuminate\Contracts\Support\Renderable
|
| 23 |
+
*/
|
| 24 |
+
public function index()
|
| 25 |
+
{
|
| 26 |
+
return view('home');
|
| 27 |
+
}
|
| 28 |
+
}
|
app/app/Http/Controllers/JustificanteController.php
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Justificante;
|
| 6 |
+
use App\Models\Alumno;
|
| 7 |
+
use App\Models\Persona;
|
| 8 |
+
use App\Models\Periodo;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use Illuminate\Support\Facades\Auth;
|
| 11 |
+
use Barryvdh\DomPDF\Facade\Pdf;
|
| 12 |
+
use Illuminate\Http\Request;
|
| 13 |
+
|
| 14 |
+
class JustificanteController extends Controller
|
| 15 |
+
{
|
| 16 |
+
/**
|
| 17 |
+
* Display a listing of the resource.
|
| 18 |
+
*/
|
| 19 |
+
public function index()
|
| 20 |
+
{
|
| 21 |
+
$usuario = Auth::user();
|
| 22 |
+
$persona = $usuario->persona;
|
| 23 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 24 |
+
|
| 25 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 26 |
+
$justificantes = Justificante::with('alumno.persona', 'alumno.grupo')->get();
|
| 27 |
+
return view('admin.justificantes.index', compact('justificantes'));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 31 |
+
->pluck('id_grupo')
|
| 32 |
+
->toArray();
|
| 33 |
+
|
| 34 |
+
if (empty($gruposAsignados)) {
|
| 35 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$justificantes = Justificante::whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 39 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 40 |
+
})->with('alumno.persona', 'alumno.grupo')->get();
|
| 41 |
+
|
| 42 |
+
return view('admin.justificantes.index', compact('justificantes'));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Show the form for creating a new resource.
|
| 47 |
+
*/
|
| 48 |
+
public function create()
|
| 49 |
+
{
|
| 50 |
+
$usuario = auth()->user();
|
| 51 |
+
$persona = $usuario->persona;
|
| 52 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 53 |
+
|
| 54 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 55 |
+
$alumnos = Alumno::with('persona')->get();
|
| 56 |
+
} else {
|
| 57 |
+
|
| 58 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 59 |
+
->pluck('id_grupo');
|
| 60 |
+
|
| 61 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
$personas = Persona::all();
|
| 65 |
+
return view('admin.justificantes.create', compact('alumnos', 'personas'));
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Store a newly created resource in storage.
|
| 70 |
+
*/
|
| 71 |
+
public function store(Request $request)
|
| 72 |
+
{
|
| 73 |
+
$usuario = auth()->user();
|
| 74 |
+
$persona = $usuario->persona;
|
| 75 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 76 |
+
|
| 77 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 78 |
+
|
| 79 |
+
if ($rolNombre == 'Administrador') {
|
| 80 |
+
|
| 81 |
+
} else {
|
| 82 |
+
|
| 83 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 84 |
+
->pluck('id_grupo');
|
| 85 |
+
|
| 86 |
+
if (!$alumno || !$gruposAsignados->contains($alumno->id_grupo)) {
|
| 87 |
+
return redirect()->back()->with('error', 'No tienes permiso para justificar a este alumno.');
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
//dd($request->all());
|
| 91 |
+
$request->validate([
|
| 92 |
+
'id_alumno' => 'required|string|max:50',
|
| 93 |
+
'persona_id' => 'required|string|max:50',
|
| 94 |
+
'motivo' => 'required|string|max:250',
|
| 95 |
+
'fecha' => 'required|date|max:50',
|
| 96 |
+
]);
|
| 97 |
+
|
| 98 |
+
$justificantes = new Justificante();
|
| 99 |
+
$justificantes->id_alumno = $request->id_alumno;
|
| 100 |
+
$justificantes->persona_id = $request->persona_id;
|
| 101 |
+
$justificantes->motivo = $request->motivo;
|
| 102 |
+
$justificantes->fecha = $request->fecha;
|
| 103 |
+
$justificantes->save();
|
| 104 |
+
|
| 105 |
+
return redirect()->route('justificantes.index')->with('mensaje', 'Justificante creado con éxito.')
|
| 106 |
+
->with('icono', 'success');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
public function pdf($id)
|
| 110 |
+
{
|
| 111 |
+
$usuario = Auth::user();
|
| 112 |
+
$persona = optional($usuario->persona);
|
| 113 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 114 |
+
|
| 115 |
+
$justificantes = Justificante::with(['alumno.persona'])->findOrFail($id);
|
| 116 |
+
$alumno = $justificantes->alumno;
|
| 117 |
+
|
| 118 |
+
if (!$alumno) {
|
| 119 |
+
return redirect()->back()->with('error', 'No se encontró el alumno asociado al justificante.');
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 123 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 124 |
+
->pluck('id_grupo')
|
| 125 |
+
->toArray();
|
| 126 |
+
|
| 127 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 128 |
+
abort(403, 'Acceso denegado: No puedes ver este PDF.');
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
$tutor = $alumno->tutor->persona ?? null;
|
| 133 |
+
$elaborador = $justificantes->elaborador ?? null;
|
| 134 |
+
|
| 135 |
+
$periodo = Periodo::latest()->first();
|
| 136 |
+
|
| 137 |
+
$pdf = PDF::loadView('admin.justificantes.pdf', compact('alumno', 'justificantes', 'periodo', 'tutor', 'elaborador'));
|
| 138 |
+
|
| 139 |
+
return $pdf->stream();
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Display the specified resource.
|
| 144 |
+
*/
|
| 145 |
+
public function show(string $id)
|
| 146 |
+
{
|
| 147 |
+
$usuario = Auth::user();
|
| 148 |
+
$persona = $usuario->persona;
|
| 149 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 150 |
+
|
| 151 |
+
$justificantes = Justificante::with('alumno.persona', 'creador')->findOrFail($id);
|
| 152 |
+
$alumno = $justificantes->alumno;
|
| 153 |
+
$personaAlumno = $alumno->persona;
|
| 154 |
+
$creador = $justificantes->creador;
|
| 155 |
+
$motivo = $justificantes->motivo;
|
| 156 |
+
$fecha = $justificantes->fecha;
|
| 157 |
+
|
| 158 |
+
//dd($justificantes->creador);
|
| 159 |
+
|
| 160 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 161 |
+
return view('admin.justificantes.show', compact('alumno', 'personaAlumno', 'creador', 'motivo', 'fecha'));
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $usuario->persona_id)
|
| 165 |
+
->pluck('id_grupo')
|
| 166 |
+
->toArray();
|
| 167 |
+
|
| 168 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 169 |
+
abort(403, 'Acceso denegado. No puedes ver este justificante.');
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
return view('admin.justificantes.show', compact('alumno', 'personaAlumno', 'creador', 'motivo', 'fecha'));
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Show the form for editing the specified resource.
|
| 177 |
+
*/
|
| 178 |
+
public function edit(string $id)
|
| 179 |
+
{
|
| 180 |
+
$usuario = Auth::user();
|
| 181 |
+
$persona = optional($usuario->persona);
|
| 182 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 183 |
+
|
| 184 |
+
$justificantes = Justificante::with('alumno')->findOrFail($id);
|
| 185 |
+
$alumno = $justificantes->alumno;
|
| 186 |
+
|
| 187 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 188 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 189 |
+
->pluck('id_grupo')
|
| 190 |
+
->toArray();
|
| 191 |
+
|
| 192 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 193 |
+
abort(403, 'Acceso denegado: No puedes editar este justificante.');
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
$alumnos = Alumno::all();
|
| 198 |
+
$personas = Persona::all();
|
| 199 |
+
|
| 200 |
+
return view('admin.justificantes.edit', compact('alumnos', 'personas', 'justificantes'));
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Update the specified resource in storage.
|
| 205 |
+
*/
|
| 206 |
+
public function update(Request $request, string $id)
|
| 207 |
+
{
|
| 208 |
+
$usuario = Auth::user();
|
| 209 |
+
$persona = optional($usuario->persona);
|
| 210 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 211 |
+
|
| 212 |
+
$justificantes = Justificante::findOrFail($id);
|
| 213 |
+
$alumno = $justificantes->alumno;
|
| 214 |
+
|
| 215 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 216 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 217 |
+
->pluck('id_grupo')
|
| 218 |
+
->toArray();
|
| 219 |
+
|
| 220 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 221 |
+
abort(403, 'Acceso denegado: No puedes modificar este justificante.');
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
//dd($request->all());
|
| 225 |
+
$request->validate([
|
| 226 |
+
'id_alumno' => 'nullable|string|max:50',
|
| 227 |
+
'persona_id' => 'nullable|string|max:50',
|
| 228 |
+
'motivo' => 'required|string|max:255',
|
| 229 |
+
'fecha' => 'required|date|max:50'
|
| 230 |
+
]);
|
| 231 |
+
|
| 232 |
+
$justificantes = Justificante::findOrFail($id);
|
| 233 |
+
$justificantes->id_alumno = $request->id_alumno;
|
| 234 |
+
$justificantes->persona_id = $request->persona_id;
|
| 235 |
+
$justificantes->motivo = $request->motivo;
|
| 236 |
+
$justificantes->fecha = $request->fecha;
|
| 237 |
+
$justificantes->save();
|
| 238 |
+
|
| 239 |
+
return redirect()->route('justificantes.index')->with('mensaje', 'Justificante actualizado con éxito.')
|
| 240 |
+
->with('icono', 'success');
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* Remove the specified resource from storage.
|
| 245 |
+
*/
|
| 246 |
+
public function destroy(string $id)
|
| 247 |
+
{
|
| 248 |
+
$justificantes = Justificante::findOrFail($id);
|
| 249 |
+
$justificantes->delete();
|
| 250 |
+
return redirect()->route('Justificantes.index')->with('mensaje', 'Justificante eliminado con éxito.')
|
| 251 |
+
->with('icono', 'success');
|
| 252 |
+
}
|
| 253 |
+
}
|
app/app/Http/Controllers/JustificanteMaestroController.php
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\JustificanteMaestro;
|
| 6 |
+
use App\Models\Maestro;
|
| 7 |
+
use App\Models\Persona;
|
| 8 |
+
use App\Models\Periodo;
|
| 9 |
+
use Barryvdh\DomPDF\Facade\Pdf;
|
| 10 |
+
use App\Http\Controllers\Controller;
|
| 11 |
+
use Illuminate\Http\Request;
|
| 12 |
+
|
| 13 |
+
class JustificanteMaestroController extends Controller
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* Display a listing of the resource.
|
| 17 |
+
*/
|
| 18 |
+
public function index()
|
| 19 |
+
{
|
| 20 |
+
$justificantes = JustificanteMaestro::all();
|
| 21 |
+
return view('admin.justificantemaestro.index', ['justificantes'=>$justificantes]);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Show the form for creating a new resource.
|
| 26 |
+
*/
|
| 27 |
+
public function create()
|
| 28 |
+
{
|
| 29 |
+
$maestros= Maestro::all();
|
| 30 |
+
$personas = Persona::all();
|
| 31 |
+
return view('admin.justificantemaestro.create', compact('maestros', 'personas'));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Store a newly created resource in storage.
|
| 36 |
+
*/
|
| 37 |
+
public function store(Request $request)
|
| 38 |
+
{
|
| 39 |
+
$request->validate([
|
| 40 |
+
'id_maestro' => 'required|string|max:50',
|
| 41 |
+
'persona_id' => 'required|string|max:50',
|
| 42 |
+
'motivo' => 'required|string|max:250',
|
| 43 |
+
'fecha' => 'required|date|max:50',
|
| 44 |
+
]);
|
| 45 |
+
|
| 46 |
+
$justificantes = new JustificanteMaestro();
|
| 47 |
+
$justificantes->id_maestro = $request->id_maestro;
|
| 48 |
+
$justificantes->persona_id = $request->persona_id;
|
| 49 |
+
$justificantes->motivo = $request->motivo;
|
| 50 |
+
$justificantes->fecha = $request->fecha;
|
| 51 |
+
$justificantes->save();
|
| 52 |
+
|
| 53 |
+
return redirect()->route('justificantemaestro.index')->with('mensaje', 'Justificante creado con éxito.')
|
| 54 |
+
->with('icono', 'success');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
public function pdf($id)
|
| 59 |
+
{
|
| 60 |
+
$maestro = Maestro::findOrFail($id);
|
| 61 |
+
$periodo = Periodo::findOrFail($id);
|
| 62 |
+
$justificante = JustificanteMaestro::findOrFail($id);
|
| 63 |
+
$elaborador = $justificante->elaborador ?? null;
|
| 64 |
+
$pdf = PDF::loadView('admin.justificantemaestro.pdf', compact('maestro', 'justificante', 'periodo', 'elaborador'));
|
| 65 |
+
return $pdf->stream();
|
| 66 |
+
//return view('admin.justificantemaestro.pdf');
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Display the specified resource.
|
| 71 |
+
*/
|
| 72 |
+
public function show(string $id)
|
| 73 |
+
{
|
| 74 |
+
$justificantes = JustificanteMaestro::with('maestro', 'persona')->findOrFail($id);
|
| 75 |
+
$maestro = $justificantes->maestro;
|
| 76 |
+
$persona = $justificantes->persona;
|
| 77 |
+
$motivo = $justificantes->motivo;
|
| 78 |
+
$fecha = $justificantes->fecha;
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
return view('admin.justificantemaestro.show', [
|
| 82 |
+
'maestro' => $maestro,
|
| 83 |
+
'persona' => $persona,
|
| 84 |
+
'motivo' => $motivo,
|
| 85 |
+
'fecha' => $fecha
|
| 86 |
+
]);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Show the form for editing the specified resource.
|
| 91 |
+
*/
|
| 92 |
+
public function edit(string $id)
|
| 93 |
+
{
|
| 94 |
+
$justificantes = JustificanteMaestro::findOrFail($id);
|
| 95 |
+
$maestros = Maestro::all();
|
| 96 |
+
$personas = Persona::all();
|
| 97 |
+
return view('admin.justificantemaestro.edit', compact('maestros', 'personas', 'justificantes'));
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Update the specified resource in storage.
|
| 102 |
+
*/
|
| 103 |
+
public function update(Request $request, string $id)
|
| 104 |
+
{
|
| 105 |
+
$request->validate([
|
| 106 |
+
'id_maestro' => 'nullable|string|max:50',
|
| 107 |
+
'persona_id' => 'nullable|string|max:50',
|
| 108 |
+
'motivo' => 'required|string|max:255',
|
| 109 |
+
'fecha' => 'required|date|max:50'
|
| 110 |
+
]);
|
| 111 |
+
|
| 112 |
+
$justificantes = JustificanteMaestro::findOrFail($id);
|
| 113 |
+
$justificantes->id_maestro = $request->id_maestro;
|
| 114 |
+
$justificantes->persona_id = $request->persona_id;
|
| 115 |
+
$justificantes->motivo = $request->motivo;
|
| 116 |
+
$justificantes->fecha = $request->fecha;
|
| 117 |
+
$justificantes->save();
|
| 118 |
+
|
| 119 |
+
return redirect()->route('justificantemaestro.index')->with('mensaje', 'Justificante actualizado con éxito.')
|
| 120 |
+
->with('icono', 'success');
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Remove the specified resource from storage.
|
| 125 |
+
*/
|
| 126 |
+
public function destroy(string $id)
|
| 127 |
+
{
|
| 128 |
+
$justificantes = JustificanteMaestro::findOrFail($id);
|
| 129 |
+
$justificantes->delete();
|
| 130 |
+
return redirect()->route('Justificantemaestro.index')->with('mensaje', 'Justificante eliminado con éxito.')
|
| 131 |
+
->with('icono', 'success');
|
| 132 |
+
}
|
| 133 |
+
}
|
app/app/Http/Controllers/MaestroController.php
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Maestro;
|
| 6 |
+
use App\Models\Persona;
|
| 7 |
+
use App\Http\Controllers\Controller;
|
| 8 |
+
use Illuminate\Http\Request;
|
| 9 |
+
|
| 10 |
+
class MaestroController extends Controller
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Display a listing of the resource.
|
| 14 |
+
*/
|
| 15 |
+
public function index()
|
| 16 |
+
{
|
| 17 |
+
$maestros = Maestro::all();
|
| 18 |
+
return view('admin.maestros.index', ['maestros'=>$maestros]);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Show the form for creating a new resource.
|
| 23 |
+
*/
|
| 24 |
+
public function create()
|
| 25 |
+
{
|
| 26 |
+
$personas = Persona::all();
|
| 27 |
+
return view('admin.maestros.create', compact('personas'));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Store a newly created resource in storage.
|
| 32 |
+
*/
|
| 33 |
+
public function store(Request $request)
|
| 34 |
+
{
|
| 35 |
+
$request->validate([
|
| 36 |
+
'persona_id' => 'required|exists:personas,id_persona|unique:maestros,persona_id',
|
| 37 |
+
]);
|
| 38 |
+
|
| 39 |
+
$maestros = new Maestro();
|
| 40 |
+
$maestros->persona_id = $request->persona_id;
|
| 41 |
+
$maestros->save();
|
| 42 |
+
|
| 43 |
+
return redirect()->route('maestros.index')->with('mensaje', 'Maestro creado con éxito.')
|
| 44 |
+
->with('icono', 'success');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Display the specified resource.
|
| 49 |
+
*/
|
| 50 |
+
public function show(string $id)
|
| 51 |
+
{
|
| 52 |
+
$maestro = Maestro::with('persona')->findOrFail($id);
|
| 53 |
+
$persona = $maestro->persona;
|
| 54 |
+
|
| 55 |
+
return view('admin.maestros.show', [
|
| 56 |
+
'maestro' => $maestro,
|
| 57 |
+
'persona' => $persona,
|
| 58 |
+
]);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Show the form for editing the specified resource.
|
| 63 |
+
*/
|
| 64 |
+
public function edit(string $id)
|
| 65 |
+
{
|
| 66 |
+
$maestro = Maestro::with('persona')->findOrFail($id);
|
| 67 |
+
return view('admin.maestros.edit', ['maestro' => $maestro]);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Update the specified resource in storage.
|
| 72 |
+
*/
|
| 73 |
+
public function update(Request $request, string $id)
|
| 74 |
+
{
|
| 75 |
+
$request->validate([
|
| 76 |
+
'nombre' => 'required|string|max:255',
|
| 77 |
+
'apellido_paterno' => 'required|string|max:255',
|
| 78 |
+
'apellido_materno' => 'required|string|max:255',
|
| 79 |
+
]);
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
$maestro = Maestro::findOrFail($id);
|
| 83 |
+
$persona = $maestro->persona;
|
| 84 |
+
$persona->nombre = $request->nombre;
|
| 85 |
+
$persona->apellido_paterno = $request->apellido_paterno;
|
| 86 |
+
$persona->apellido_materno = $request->apellido_materno;
|
| 87 |
+
$maestro->persona->save();
|
| 88 |
+
|
| 89 |
+
return redirect()->route('maestros.index')->with('mensaje', 'Maestros actualizado con éxito.')
|
| 90 |
+
->with('icono', 'success');
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Remove the specified resource from storage.
|
| 95 |
+
*/
|
| 96 |
+
public function destroy(string $id)
|
| 97 |
+
{
|
| 98 |
+
$maestro = Maestro::find($id);
|
| 99 |
+
$maestro->delete();
|
| 100 |
+
|
| 101 |
+
return redirect()->route('maestros.index')->with('mensaje', 'Maestro eliminado con éxito.')
|
| 102 |
+
->with('icono', 'success');
|
| 103 |
+
}
|
| 104 |
+
}
|
app/app/Http/Controllers/MateriaController.php
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Materia;
|
| 6 |
+
use App\Models\Grupo;
|
| 7 |
+
use App\Models\GrupoPrefecto;
|
| 8 |
+
use Illuminate\Validation\Rule;
|
| 9 |
+
use Illuminate\Http\Request;
|
| 10 |
+
|
| 11 |
+
class MateriaController extends Controller
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Display a listing of the resource.
|
| 15 |
+
*/
|
| 16 |
+
public function index()
|
| 17 |
+
{
|
| 18 |
+
$usuario = auth()->user();
|
| 19 |
+
$persona = $usuario->persona;
|
| 20 |
+
|
| 21 |
+
if (in_array($usuario->rol->nombre_rol, ['Administrador', 'Coordinador'])) {
|
| 22 |
+
$materias = Materia::all();
|
| 23 |
+
} else {
|
| 24 |
+
|
| 25 |
+
$gradosAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 26 |
+
->pluck('id_grupo')
|
| 27 |
+
->unique();
|
| 28 |
+
|
| 29 |
+
if ($gradosAsignados->isEmpty()) {
|
| 30 |
+
return redirect()->back()->with('error', 'No tienes grados asignados.');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
$materias = Materia::whereIn('grado', Grupo::whereIn('id_grupo', $gradosAsignados)->pluck('grado'))->get();
|
| 34 |
+
}
|
| 35 |
+
return view('admin.materias.index', ['materias'=>$materias]);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Show the form for creating a new resource.
|
| 40 |
+
*/
|
| 41 |
+
public function create()
|
| 42 |
+
{
|
| 43 |
+
return view('admin.materias.create');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Store a newly created resource in storage.
|
| 48 |
+
*/
|
| 49 |
+
public function store(Request $request)
|
| 50 |
+
{
|
| 51 |
+
$request->validate([
|
| 52 |
+
'nombre_materia' => 'required|string|max:100|unique:materias,nombre_materia',
|
| 53 |
+
'grado' => 'required|integer|min:1|max:3'
|
| 54 |
+
]);
|
| 55 |
+
|
| 56 |
+
$materias = new Materia();
|
| 57 |
+
$materias->nombre_materia = $request->nombre_materia;
|
| 58 |
+
$materias->grado = $request->grado;
|
| 59 |
+
$materias->save();
|
| 60 |
+
|
| 61 |
+
return redirect()->route('materias.index')->with('mensaje', 'Se registro la materia de la manera correcta')
|
| 62 |
+
->with('icono', 'success');
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Display the specified resource.
|
| 67 |
+
*/
|
| 68 |
+
public function show(string $id)
|
| 69 |
+
{
|
| 70 |
+
$materias = Materia::findOrFail($id);
|
| 71 |
+
return view('admin.materias.show', ['materias'=>$materias]);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Show the form for editing the specified resource.
|
| 76 |
+
*/
|
| 77 |
+
public function edit(string $id)
|
| 78 |
+
{
|
| 79 |
+
$materias = Materia::findOrFail($id);
|
| 80 |
+
return view('admin.materias.edit', ['materias'=>$materias]);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Update the specified resource in storage.
|
| 85 |
+
*/
|
| 86 |
+
public function update(Request $request, string $id)
|
| 87 |
+
{
|
| 88 |
+
$request->validate([
|
| 89 |
+
'nombre_materia' => ['required', 'string', 'max:100', Rule::unique('materias', 'nombre_materia')->ignore($id, 'id_materia')],
|
| 90 |
+
'grado' => 'required|integer|min:1|max:3'
|
| 91 |
+
]);
|
| 92 |
+
|
| 93 |
+
$materias = Materia::find($id);
|
| 94 |
+
$materias->nombre_materia = $request->nombre_materia;
|
| 95 |
+
$materias->grado = $request->grado;
|
| 96 |
+
$materias->save();
|
| 97 |
+
|
| 98 |
+
return redirect()->route('materias.index')->with('mensaje', 'Se actualizo la materia de la manera correcta')
|
| 99 |
+
->with('icono', 'success');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Remove the specified resource from storage.
|
| 104 |
+
*/
|
| 105 |
+
public function destroy(string $id)
|
| 106 |
+
{
|
| 107 |
+
Materia::destroy($id);
|
| 108 |
+
return redirect()->route('materias.index')->with('mensaje', 'Se elimino la materia de la manera correcta')
|
| 109 |
+
->with('icono', 'success');
|
| 110 |
+
}
|
| 111 |
+
}
|
app/app/Http/Controllers/PeriodoController.php
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Periodo;
|
| 6 |
+
use Illuminate\Validation\Rule;
|
| 7 |
+
use Illuminate\Http\Request;
|
| 8 |
+
|
| 9 |
+
class PeriodoController extends Controller
|
| 10 |
+
{
|
| 11 |
+
/**
|
| 12 |
+
* Display a listing of the resource.
|
| 13 |
+
*/
|
| 14 |
+
public function index()
|
| 15 |
+
{
|
| 16 |
+
$periodos = Periodo::all();
|
| 17 |
+
return view('admin.periodos.index', ['periodos'=>$periodos]);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Show the form for creating a new resource.
|
| 22 |
+
*/
|
| 23 |
+
public function create()
|
| 24 |
+
{
|
| 25 |
+
return view('admin.periodos.create');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Store a newly created resource in storage.
|
| 30 |
+
*/
|
| 31 |
+
public function store(Request $request)
|
| 32 |
+
{
|
| 33 |
+
$request->validate([
|
| 34 |
+
'nombre_periodo' => 'required|string|max:100|unique:periodos,nombre_periodo',
|
| 35 |
+
'estado' => 'required|in:activo,inactivo',
|
| 36 |
+
]);
|
| 37 |
+
|
| 38 |
+
$periodos = new Periodo();
|
| 39 |
+
$periodos->nombre_periodo = $request->nombre_periodo;
|
| 40 |
+
$periodos->estado = $request->estado;
|
| 41 |
+
$periodos->save();
|
| 42 |
+
|
| 43 |
+
return redirect()->route('periodos.index')->with('mensaje', 'Se registro el periodo de la manera correcta')
|
| 44 |
+
->with('icono', 'success');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Display the specified resource.
|
| 49 |
+
*/
|
| 50 |
+
public function show(string $id)
|
| 51 |
+
{
|
| 52 |
+
$periodos = Periodo::findOrFail($id);
|
| 53 |
+
return view('admin.periodos.show', ['periodos'=>$periodos]);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Show the form for editing the specified resource.
|
| 58 |
+
*/
|
| 59 |
+
public function edit(string $id)
|
| 60 |
+
{
|
| 61 |
+
$periodos = Periodo::findOrFail($id);
|
| 62 |
+
return view('admin.periodos.edit', ['periodos'=>$periodos]);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Update the specified resource in storage.
|
| 67 |
+
*/
|
| 68 |
+
public function update(Request $request, string $id)
|
| 69 |
+
{
|
| 70 |
+
$request->validate([
|
| 71 |
+
'nombre_periodo' => ['required', 'string', 'max:100', Rule::unique('periodos', 'nombre_periodo')->ignore($id, 'id_periodo')],
|
| 72 |
+
'estado' => 'required|in:activo,inactivo'
|
| 73 |
+
]);
|
| 74 |
+
|
| 75 |
+
$periodos = Periodo::find($id);
|
| 76 |
+
$periodos->nombre_periodo = $request->nombre_periodo;
|
| 77 |
+
$periodos->estado = $request->estado;
|
| 78 |
+
$periodos->save();
|
| 79 |
+
|
| 80 |
+
return redirect()->route('periodos.index')->with('mensaje', 'Se actualizo el periodo de la manera correcta')
|
| 81 |
+
->with('icono', 'success');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Remove the specified resource from storage.
|
| 86 |
+
*/
|
| 87 |
+
public function destroy(string $id)
|
| 88 |
+
{
|
| 89 |
+
Periodo::destroy($id);
|
| 90 |
+
return redirect()->route('periodos.index')->with('mensaje', 'Se elimino el periodo de la manera correcta')
|
| 91 |
+
->with('icono', 'success');
|
| 92 |
+
}
|
| 93 |
+
}
|
app/app/Http/Controllers/PersonaController.php
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Persona;
|
| 6 |
+
use App\Models\Rol;
|
| 7 |
+
use Illuminate\Http\Request;
|
| 8 |
+
use Illuminate\Validation\Rule;
|
| 9 |
+
use Illuminate\Support\Facades\Validator;
|
| 10 |
+
|
| 11 |
+
class PersonaController extends Controller
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Display a listing of the resource.
|
| 15 |
+
*/
|
| 16 |
+
public function index()
|
| 17 |
+
{
|
| 18 |
+
$personas = Persona::all();
|
| 19 |
+
return view('admin.personas.index', ['personas'=>$personas]);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Show the form for creating a new resource.
|
| 24 |
+
*/
|
| 25 |
+
public function create()
|
| 26 |
+
{
|
| 27 |
+
$roles = Rol::all();
|
| 28 |
+
return view('admin.personas.create', compact('roles'));
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Store a newly created resource in storage.
|
| 33 |
+
*/
|
| 34 |
+
public function store(Request $request)
|
| 35 |
+
{
|
| 36 |
+
//dd($request->all());
|
| 37 |
+
$request->validate([
|
| 38 |
+
'nombre' => 'required|string|max:255',
|
| 39 |
+
'apellido_paterno' => 'required|string|max:255',
|
| 40 |
+
'apellido_materno' => 'required|string|max:255',
|
| 41 |
+
'direccion' => 'required|string|max:255',
|
| 42 |
+
'fecha_nacimiento' => ['required', 'date', 'before:today'],
|
| 43 |
+
'telefono' => 'required|string|max:255|unique:personas,telefono',
|
| 44 |
+
'curp' => 'required|string|max:18|unique:personas,curp',
|
| 45 |
+
'id_rol' => 'nullable|exists:roles,id_rol'
|
| 46 |
+
]);
|
| 47 |
+
|
| 48 |
+
$persona = new Persona();
|
| 49 |
+
$persona->nombre = $request->nombre;
|
| 50 |
+
$persona->apellido_paterno = $request->apellido_paterno;
|
| 51 |
+
$persona->apellido_materno = $request->apellido_materno;
|
| 52 |
+
$persona->direccion = $request->direccion;
|
| 53 |
+
$persona->fecha_nacimiento = $request->fecha_nacimiento;
|
| 54 |
+
$persona->telefono = $request->telefono;
|
| 55 |
+
$persona->curp = $request->curp;
|
| 56 |
+
$persona->id_rol = $request->id_rol;
|
| 57 |
+
$persona->save();
|
| 58 |
+
|
| 59 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona creada con éxito.')
|
| 60 |
+
->with('icono', 'success');
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Display the specified resource.
|
| 65 |
+
*/
|
| 66 |
+
public function show($id)
|
| 67 |
+
{
|
| 68 |
+
$personas = Persona::findOrFail($id);
|
| 69 |
+
$roles = Rol::all();
|
| 70 |
+
return view('admin.personas.show', ['personas'=>$personas]);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Show the form for editing the specified resource.
|
| 75 |
+
*/
|
| 76 |
+
public function edit($id)
|
| 77 |
+
{
|
| 78 |
+
$persona = Persona::with(['usuario', 'alumno', 'tutor',])->findOrFail($id);
|
| 79 |
+
$roles = Rol::all();
|
| 80 |
+
return view('admin.personas.edit', compact('persona', 'roles'));
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Update the specified resource in storage.
|
| 85 |
+
*/
|
| 86 |
+
public function update(Request $request, string $id)
|
| 87 |
+
{
|
| 88 |
+
$request->validate([
|
| 89 |
+
'nombre' => 'required|string|max:50',
|
| 90 |
+
'apellido_paterno' => 'required|string|max:50',
|
| 91 |
+
'apellido_materno' => 'required|string|max:50',
|
| 92 |
+
'direccion' => 'required|string|max:50',
|
| 93 |
+
'fecha_nacimiento' => ['required', 'date', 'before:today'],
|
| 94 |
+
'telefono' => ['required', 'string', 'max:10', Rule::unique('personas', 'telefono')->ignore($id, 'id_persona')],
|
| 95 |
+
'id_rol' => 'required|integer',
|
| 96 |
+
'curp' => ['required', 'string', 'max:18', Rule::unique('personas', 'curp')->ignore($id, 'id_persona')],
|
| 97 |
+
]);
|
| 98 |
+
|
| 99 |
+
$personas = Persona::findOrFail($id);
|
| 100 |
+
$personas->nombre = $request->nombre;
|
| 101 |
+
$personas->apellido_paterno = $request->apellido_paterno;
|
| 102 |
+
$personas->apellido_materno = $request->apellido_materno;
|
| 103 |
+
$personas->direccion = $request->direccion;
|
| 104 |
+
$personas->fecha_nacimiento = $request->fecha_nacimiento;
|
| 105 |
+
$personas->telefono = $request->telefono;
|
| 106 |
+
$personas->id_rol = $request->id_rol;
|
| 107 |
+
$personas->curp = $request->curp;
|
| 108 |
+
$personas->save();
|
| 109 |
+
|
| 110 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona actualizada con éxito.')
|
| 111 |
+
->with('icono', 'success');
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* Remove the specified resource from storage.
|
| 116 |
+
*/
|
| 117 |
+
public function destroy(string $id)
|
| 118 |
+
{
|
| 119 |
+
$personas = Persona::findOrFail($id);
|
| 120 |
+
$personas->delete();
|
| 121 |
+
|
| 122 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona eliminada con éxito.')
|
| 123 |
+
->with('icono', 'success');
|
| 124 |
+
}
|
| 125 |
+
}
|
app/app/Http/Controllers/ReporteController.php
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Reporte;
|
| 6 |
+
use App\Models\Alumno;
|
| 7 |
+
use App\Models\Persona;
|
| 8 |
+
use App\Models\Periodo;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use Illuminate\Support\Facades\Auth;
|
| 11 |
+
use Barryvdh\DomPDF\Facade\Pdf;
|
| 12 |
+
use Illuminate\Http\Request;
|
| 13 |
+
|
| 14 |
+
class ReporteController extends Controller
|
| 15 |
+
{
|
| 16 |
+
/**
|
| 17 |
+
* Display a listing of the resource.
|
| 18 |
+
*/
|
| 19 |
+
public function index()
|
| 20 |
+
{
|
| 21 |
+
$usuario = Auth::user();
|
| 22 |
+
$persona = $usuario->persona;
|
| 23 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 24 |
+
|
| 25 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 26 |
+
$reportes = Reporte::with('alumno.persona', 'alumno.grupo')->get();
|
| 27 |
+
return view('admin.reportes.index', compact('reportes'));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 31 |
+
->pluck('id_grupo')
|
| 32 |
+
->toArray();
|
| 33 |
+
|
| 34 |
+
if (empty($gruposAsignados)) {
|
| 35 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$reportes = Reporte::whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 39 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 40 |
+
})->with('alumno.persona', 'alumno.grupo')->get();
|
| 41 |
+
|
| 42 |
+
return view('admin.reportes.index', compact('reportes'));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Show the form for creating a new resource.
|
| 47 |
+
*/
|
| 48 |
+
public function create()
|
| 49 |
+
{
|
| 50 |
+
$usuario = auth()->user();
|
| 51 |
+
$persona = $usuario->persona;
|
| 52 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 53 |
+
|
| 54 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 55 |
+
$alumnos = Alumno::with('persona')->get();
|
| 56 |
+
} else {
|
| 57 |
+
|
| 58 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 59 |
+
->pluck('id_grupo');
|
| 60 |
+
|
| 61 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
$personas = Persona::all();
|
| 65 |
+
return view('admin.reportes.create', compact('alumnos', 'personas'));
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Store a newly created resource in storage.
|
| 70 |
+
*/
|
| 71 |
+
public function store(Request $request)
|
| 72 |
+
{
|
| 73 |
+
$usuario = auth()->user();
|
| 74 |
+
$persona = $usuario->persona;
|
| 75 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 76 |
+
|
| 77 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 78 |
+
|
| 79 |
+
if ($rolNombre == 'Administrador') {
|
| 80 |
+
|
| 81 |
+
} else {
|
| 82 |
+
|
| 83 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 84 |
+
->pluck('id_grupo');
|
| 85 |
+
|
| 86 |
+
if (!$alumno || !$gruposAsignados->contains($alumno->id_grupo)) {
|
| 87 |
+
return redirect()->back()->with('error', 'No tienes permiso para hacer este reporte a este alumno.');
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
//dd($request->all());
|
| 91 |
+
$request->validate([
|
| 92 |
+
'id_alumno' => 'required|string|max:50',
|
| 93 |
+
'persona_id' => 'required|string|max:50',
|
| 94 |
+
'contenido' => 'required|string|max:255',
|
| 95 |
+
'fecha' => 'required|date|max:50'
|
| 96 |
+
]);
|
| 97 |
+
|
| 98 |
+
$reportes = new Reporte();
|
| 99 |
+
$reportes->id_alumno = $request->id_alumno;
|
| 100 |
+
$reportes->persona_id = $request->persona_id;
|
| 101 |
+
$reportes->contenido = $request->contenido;
|
| 102 |
+
$reportes->fecha = $request->fecha;
|
| 103 |
+
$reportes->save();
|
| 104 |
+
|
| 105 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reporte creado con éxito.')
|
| 106 |
+
->with('icono', 'success');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
public function pdf($id)
|
| 110 |
+
{
|
| 111 |
+
$usuario = Auth::user();
|
| 112 |
+
$persona = optional($usuario->persona);
|
| 113 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 114 |
+
|
| 115 |
+
$reportes = Reporte::with(['alumno.persona'])->findOrFail($id);
|
| 116 |
+
$alumno = $reportes->alumno;
|
| 117 |
+
|
| 118 |
+
if (!$alumno) {
|
| 119 |
+
return redirect()->back()->with('error', 'No se encontró el alumno asociado al reporte.');
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 123 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 124 |
+
->pluck('id_grupo')
|
| 125 |
+
->toArray();
|
| 126 |
+
|
| 127 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 128 |
+
abort(403, 'Acceso denegado: No puedes ver este PDF.');
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
$tutor = $alumno->tutor->persona ?? null;
|
| 133 |
+
$elaborador = $reportes->elaborador ?? null;
|
| 134 |
+
|
| 135 |
+
$periodo = Periodo::latest()->first();
|
| 136 |
+
|
| 137 |
+
$pdf = PDF::loadView('admin.reportes.pdf', compact('alumno', 'reportes', 'periodo', 'tutor', 'elaborador'));
|
| 138 |
+
|
| 139 |
+
return $pdf->stream();
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Display the specified resource.
|
| 144 |
+
*/
|
| 145 |
+
public function show(string $id)
|
| 146 |
+
{
|
| 147 |
+
$usuario = Auth::user();
|
| 148 |
+
$persona = $usuario->persona;
|
| 149 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 150 |
+
|
| 151 |
+
$reportes = Reporte::with('alumno.persona', 'creador')->findOrFail($id);
|
| 152 |
+
$alumno = $reportes->alumno;
|
| 153 |
+
$personaAlumno = $alumno->persona;
|
| 154 |
+
$creador = $reportes->creador;
|
| 155 |
+
$contenido = $reportes->contenido;
|
| 156 |
+
$fecha = $reportes->fecha;
|
| 157 |
+
|
| 158 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 159 |
+
return view('admin.reportes.show', compact('alumno', 'personaAlumno', 'creador', 'contenido', 'fecha'));
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $usuario->persona_id)
|
| 163 |
+
->pluck('id_grupo')
|
| 164 |
+
->toArray();
|
| 165 |
+
|
| 166 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 167 |
+
abort(403, 'Acceso denegado. No puedes ver este reporte.');
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
return view('admin.reportes.show', compact('alumno', 'personaAlumno', 'creador', 'contenido', 'fecha'));
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* Show the form for editing the specified resource.
|
| 175 |
+
*/
|
| 176 |
+
public function edit(string $id)
|
| 177 |
+
{
|
| 178 |
+
$usuario = Auth::user();
|
| 179 |
+
$persona = optional($usuario->persona);
|
| 180 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 181 |
+
|
| 182 |
+
$reportes = Reporte::with('alumno')->findOrFail($id);
|
| 183 |
+
$alumno = $reportes->alumno;
|
| 184 |
+
|
| 185 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 186 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 187 |
+
->pluck('id_grupo')
|
| 188 |
+
->toArray();
|
| 189 |
+
|
| 190 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 191 |
+
abort(403, 'Acceso denegado: No puedes editar este reporte.');
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
$alumnos = Alumno::all();
|
| 196 |
+
$personas = Persona::all();
|
| 197 |
+
|
| 198 |
+
return view('admin.reportes.edit', compact('alumnos', 'personas', 'reportes'));
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Update the specified resource in storage.
|
| 203 |
+
*/
|
| 204 |
+
public function update(Request $request, string $id)
|
| 205 |
+
{
|
| 206 |
+
$usuario = Auth::user();
|
| 207 |
+
$persona = optional($usuario->persona);
|
| 208 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 209 |
+
|
| 210 |
+
$reportes = Reporte::findOrFail($id);
|
| 211 |
+
$alumno = $reportes->alumno;
|
| 212 |
+
|
| 213 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 214 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 215 |
+
->pluck('id_grupo')
|
| 216 |
+
->toArray();
|
| 217 |
+
|
| 218 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 219 |
+
abort(403, 'Acceso denegado: No puedes modificar este reporte.');
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
//dd($request->all());
|
| 223 |
+
$request->validate([
|
| 224 |
+
'id_alumno' => 'nullable|string|max:50',
|
| 225 |
+
'persona_id' => 'nullable|string|max:50',
|
| 226 |
+
'contenido' => 'required|string|max:255',
|
| 227 |
+
'fecha' => 'required|date|max:50'
|
| 228 |
+
]);
|
| 229 |
+
|
| 230 |
+
$reportes = Reporte::findOrFail($id);
|
| 231 |
+
$reportes->id_alumno = $request->id_alumno;
|
| 232 |
+
$reportes->persona_id = $request->persona_id;
|
| 233 |
+
$reportes->contenido = $request->contenido;
|
| 234 |
+
$reportes->fecha = $request->fecha;
|
| 235 |
+
$reportes->save();
|
| 236 |
+
|
| 237 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reportes actualizado con éxito.')
|
| 238 |
+
->with('icono', 'success');
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* Remove the specified resource from storage.
|
| 243 |
+
*/
|
| 244 |
+
public function destroy(string $id)
|
| 245 |
+
{
|
| 246 |
+
$reportes = Reporte::findOrFail($id);
|
| 247 |
+
$reportes->delete();
|
| 248 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reporte eliminado con éxito.')
|
| 249 |
+
->with('icono', 'success');
|
| 250 |
+
}
|
| 251 |
+
}
|
app/app/Http/Controllers/RolController.php
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Rol;
|
| 6 |
+
use Illuminate\Http\Request;
|
| 7 |
+
use Illuminate\Validation\Rule;
|
| 8 |
+
use Illuminate\Support\Facades\Auth;
|
| 9 |
+
use Illuminate\Support\Facades\Validator;
|
| 10 |
+
|
| 11 |
+
class RolController extends Controller
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Display a listing of the resource.
|
| 15 |
+
*/
|
| 16 |
+
public function index()
|
| 17 |
+
{
|
| 18 |
+
$usuario = auth()->user();
|
| 19 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 20 |
+
|
| 21 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 22 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
$roles = Rol::all();
|
| 26 |
+
return view('admin.roles.index', ['roles'=>$roles]);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Show the form for creating a new resource.
|
| 31 |
+
*/
|
| 32 |
+
public function create()
|
| 33 |
+
{
|
| 34 |
+
return view('admin.roles.create');
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Store a newly created resource in storage.
|
| 39 |
+
*/
|
| 40 |
+
public function store(Request $request)
|
| 41 |
+
{
|
| 42 |
+
$request->validate([
|
| 43 |
+
'nombre_rol' => 'required|string|max:100|unique:roles,nombre_rol',
|
| 44 |
+
]);
|
| 45 |
+
|
| 46 |
+
$roles = new Rol();
|
| 47 |
+
$roles->nombre_rol = $request->nombre_rol;
|
| 48 |
+
$roles->save();
|
| 49 |
+
|
| 50 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se registro el rol de la manera correcta')
|
| 51 |
+
->with('icono', 'success');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Display the specified resource.
|
| 56 |
+
*/
|
| 57 |
+
public function show($id)
|
| 58 |
+
{
|
| 59 |
+
$roles = Rol::findOrFail($id);
|
| 60 |
+
return view('admin.roles.show', ['roles'=>$roles]);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Show the form for editing the specified resource.
|
| 65 |
+
*/
|
| 66 |
+
public function edit($id)
|
| 67 |
+
{
|
| 68 |
+
$roles = Rol::findOrFail($id);
|
| 69 |
+
return view('admin.roles.edit', ['roles'=>$roles]);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Update the specified resource in storage.
|
| 74 |
+
*/
|
| 75 |
+
public function update(Request $request, string $id)
|
| 76 |
+
{
|
| 77 |
+
$request->validate([
|
| 78 |
+
'nombre_rol' => ['required', 'string', 'max:15', Rule::unique('roles', 'nombre_rol')->ignore($id, 'id_rol')],
|
| 79 |
+
]);
|
| 80 |
+
|
| 81 |
+
$roles = Rol::find($id);
|
| 82 |
+
$roles->nombre_rol = $request->nombre_rol;
|
| 83 |
+
$roles->save();
|
| 84 |
+
|
| 85 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se actualizo el rol de la manera correcta')
|
| 86 |
+
->with('icono', 'success');
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Remove the specified resource from storage.
|
| 91 |
+
*/
|
| 92 |
+
public function destroy($id)
|
| 93 |
+
{
|
| 94 |
+
Rol::destroy($id);
|
| 95 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se elimino el rol de la manera correcta')
|
| 96 |
+
->with('icono', 'success');
|
| 97 |
+
}
|
| 98 |
+
}
|
app/app/Http/Controllers/SistemaController.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Request;
|
| 6 |
+
use App\Models\Alumno;
|
| 7 |
+
use App\Models\Calificacion;
|
| 8 |
+
use App\Models\Reporte;
|
| 9 |
+
use App\Models\Justificante;
|
| 10 |
+
use App\Models\Aviso;
|
| 11 |
+
use App\Models\JustificanteMaestro;
|
| 12 |
+
use App\Models\Materia;
|
| 13 |
+
use App\Models\Periodo;
|
| 14 |
+
use App\Models\Tutor;
|
| 15 |
+
use App\Models\Maestros;
|
| 16 |
+
use App\Models\Grupo;
|
| 17 |
+
use App\Models\GrupoPrefecto;
|
| 18 |
+
use App\Models\Persona;
|
| 19 |
+
use App\Models\Usuario;
|
| 20 |
+
|
| 21 |
+
class SistemaController extends Controller
|
| 22 |
+
{
|
| 23 |
+
public function limpiarSistema()
|
| 24 |
+
{
|
| 25 |
+
$personasExcluidas = Persona::whereHas('usuario', function ($query) {
|
| 26 |
+
$query->whereHas('rol', function ($queryRol) {
|
| 27 |
+
$queryRol->whereIn('nombre_rol', ['Administrador', 'Coordinador']);
|
| 28 |
+
});
|
| 29 |
+
})->pluck('id_persona');
|
| 30 |
+
|
| 31 |
+
Calificacion::query()->delete();
|
| 32 |
+
Reporte::query()->delete();
|
| 33 |
+
Justificante::query()->delete();
|
| 34 |
+
Aviso::query()->delete();
|
| 35 |
+
JustificanteMaestro::query()->delete();
|
| 36 |
+
|
| 37 |
+
Alumno::query()->delete();
|
| 38 |
+
Tutor::query()->delete();
|
| 39 |
+
Maestros::query()->delete();
|
| 40 |
+
|
| 41 |
+
Periodo::query()->delete();
|
| 42 |
+
Materia::query()->delete();
|
| 43 |
+
GrupoPrefecto::query()->delete();
|
| 44 |
+
Grupo::query()->delete();
|
| 45 |
+
Persona::whereNotIn('id_persona', $personasExcluidas)->delete();
|
| 46 |
+
|
| 47 |
+
return redirect()->route('admin.index')->with ('mensaje', 'Sistema limpiado correctamente.')
|
| 48 |
+
->with('icono', 'success');
|
| 49 |
+
}
|
| 50 |
+
}
|
app/app/Http/Controllers/TutorController.php
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Tutor;
|
| 6 |
+
use App\Models\Persona;
|
| 7 |
+
use App\Models\Alumno;
|
| 8 |
+
use App\Models\GrupoPrefecto;
|
| 9 |
+
use Illuminate\Http\Request;
|
| 10 |
+
|
| 11 |
+
class TutorController extends Controller
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Display a listing of the resource.
|
| 15 |
+
*/
|
| 16 |
+
public function index()
|
| 17 |
+
{
|
| 18 |
+
$usuario = auth()->user();
|
| 19 |
+
$persona = $usuario->persona;
|
| 20 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 21 |
+
|
| 22 |
+
if (in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 23 |
+
$tutores = Tutor::with('persona')->get();
|
| 24 |
+
return view('admin.tutores.index', ['tutores' => $tutores]);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)->pluck('id_grupo')->toArray();
|
| 28 |
+
|
| 29 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->pluck('id_alumno')->toArray();
|
| 30 |
+
|
| 31 |
+
$tutores = Tutor::whereHas('alumnos', function ($query) use ($alumnos) {
|
| 32 |
+
$query->whereIn('id_alumno', $alumnos);
|
| 33 |
+
})->with('persona')->get();
|
| 34 |
+
|
| 35 |
+
return view('admin.tutores.index', ['tutores'=>$tutores]);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Show the form for creating a new resource.
|
| 40 |
+
*/
|
| 41 |
+
public function create()
|
| 42 |
+
{
|
| 43 |
+
$personas = Persona::all();
|
| 44 |
+
return view('admin.tutores.create', compact('personas'));
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Store a newly created resource in storage.
|
| 49 |
+
*/
|
| 50 |
+
public function store(Request $request)
|
| 51 |
+
{
|
| 52 |
+
//dd($request->all());
|
| 53 |
+
$request->validate([
|
| 54 |
+
'persona_id' => 'required|exists:personas,id_persona|unique:tutores,persona_id',
|
| 55 |
+
]);
|
| 56 |
+
|
| 57 |
+
$tutores = new Tutor();
|
| 58 |
+
$tutores->persona_id = $request->persona_id;
|
| 59 |
+
$tutores->save();
|
| 60 |
+
|
| 61 |
+
return redirect()->route('tutores.index')->with('mensaje', 'Tutor creado con éxito.')
|
| 62 |
+
->with('icono', 'success');
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Display the specified resource.
|
| 67 |
+
*/
|
| 68 |
+
public function show(string $id)
|
| 69 |
+
{
|
| 70 |
+
$tutor = Tutor::with('persona')->findOrFail($id);
|
| 71 |
+
$persona = $tutor->persona;
|
| 72 |
+
|
| 73 |
+
return view('admin.tutores.show', [
|
| 74 |
+
'tutor' => $tutor,
|
| 75 |
+
'persona' => $persona,
|
| 76 |
+
]);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Show the form for editing the specified resource.
|
| 81 |
+
*/
|
| 82 |
+
public function edit(string $id)
|
| 83 |
+
{
|
| 84 |
+
//$tutor = Tutor::all();
|
| 85 |
+
//$personas = Persona::all();
|
| 86 |
+
//return view('admin.tutores.edit', compact('tutor', 'personas'));
|
| 87 |
+
|
| 88 |
+
$tutor = Tutor::with('persona')->findOrFail($id);
|
| 89 |
+
return view('admin.tutores.edit', ['tutor' => $tutor]);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Update the specified resource in storage.
|
| 94 |
+
*/
|
| 95 |
+
public function update(Request $request, string $id)
|
| 96 |
+
{
|
| 97 |
+
//dd($request->all());
|
| 98 |
+
$request->validate([
|
| 99 |
+
'nombre' => 'required|string|max:255',
|
| 100 |
+
'apellido_paterno' => 'required|string|max:255',
|
| 101 |
+
'apellido_materno' => 'nullable|string|max:255',
|
| 102 |
+
]);
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
$tutor = Tutor::findOrFail($id);
|
| 106 |
+
$persona = $tutor->persona;
|
| 107 |
+
$persona->nombre = $request->nombre;
|
| 108 |
+
$persona->apellido_paterno = $request->apellido_paterno;
|
| 109 |
+
$persona->apellido_materno = $request->apellido_materno;
|
| 110 |
+
//$tutor->save();
|
| 111 |
+
$tutor->persona->save();
|
| 112 |
+
|
| 113 |
+
return redirect()->route('tutores.index')->with('mensaje', 'Tutor actualizado con éxito.')
|
| 114 |
+
->with('icono', 'success');
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Remove the specified resource from storage.
|
| 119 |
+
*/
|
| 120 |
+
public function destroy(string $id)
|
| 121 |
+
{
|
| 122 |
+
$tutor = Tutor::find($id);
|
| 123 |
+
$tutor->delete();
|
| 124 |
+
|
| 125 |
+
return redirect()->route('tutores.index')->with('mensaje', 'Tutor eliminado con éxito.')
|
| 126 |
+
->with('icono', 'success');
|
| 127 |
+
}
|
| 128 |
+
}
|
app/app/Http/Controllers/UsuarioController.php
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use App\Models\Usuario;
|
| 6 |
+
use App\Models\Rol;
|
| 7 |
+
use App\Models\Persona;
|
| 8 |
+
use Illuminate\Http\Request;
|
| 9 |
+
use Illuminate\Support\Facades\Auth;
|
| 10 |
+
use Illuminate\Support\Facades\Hash;
|
| 11 |
+
use Illuminate\Validation\Rule;
|
| 12 |
+
use Illuminate\Support\Facades\Validator;
|
| 13 |
+
|
| 14 |
+
class UsuarioController extends Controller
|
| 15 |
+
{
|
| 16 |
+
/**
|
| 17 |
+
* Display a listing of the resource.
|
| 18 |
+
*/
|
| 19 |
+
public function index()
|
| 20 |
+
{
|
| 21 |
+
$usuario = auth()->user();
|
| 22 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 23 |
+
|
| 24 |
+
if (!in_array($rolNombre, ['Administrador', 'Coordinador'])) {
|
| 25 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
$usuarios = Usuario::with('persona', 'rol')->get();
|
| 29 |
+
return view('admin.usuarios.index', compact('usuarios'));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Show the form for creating a new resource.
|
| 34 |
+
*/
|
| 35 |
+
public function create()
|
| 36 |
+
{
|
| 37 |
+
$personas = Persona::all();
|
| 38 |
+
$roles = Rol::all();
|
| 39 |
+
return view('admin.usuarios.create', compact('personas', 'roles'));
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Store a newly created resource in storage.
|
| 44 |
+
*/
|
| 45 |
+
public function store(Request $request)
|
| 46 |
+
{
|
| 47 |
+
$request->validate([
|
| 48 |
+
'nombre_usuario' => 'required|string|max:50|unique:usuarios,nombre_usuario',
|
| 49 |
+
'email' => 'required|string|max:50|unique:usuarios,email',
|
| 50 |
+
'id_rol' => 'required|string|max:50',
|
| 51 |
+
'persona_id' => 'required|string|max:50',
|
| 52 |
+
'password' => 'required|confirmed'
|
| 53 |
+
|
| 54 |
+
]);
|
| 55 |
+
|
| 56 |
+
$usuarios = new Usuario();
|
| 57 |
+
$usuarios->nombre_usuario = $request->nombre_usuario;
|
| 58 |
+
$usuarios->email = $request->email;
|
| 59 |
+
$usuarios->id_rol = $request->id_rol;
|
| 60 |
+
$usuarios->persona_id = $request->persona_id;
|
| 61 |
+
$usuarios->password = Hash::make($request->password);
|
| 62 |
+
$usuarios->save();
|
| 63 |
+
|
| 64 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario creado con éxito.')
|
| 65 |
+
->with('icono', 'success');
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Display the specified resource.
|
| 70 |
+
*/
|
| 71 |
+
public function show($id)
|
| 72 |
+
{
|
| 73 |
+
$usuario = Usuario::with('persona', 'rol')->findOrFail($id);
|
| 74 |
+
$persona = $usuario->persona;
|
| 75 |
+
$rol = $usuario->rol;
|
| 76 |
+
|
| 77 |
+
return view('admin.usuarios.show', [
|
| 78 |
+
'usuario' => $usuario,
|
| 79 |
+
'persona' => $persona,
|
| 80 |
+
'rol' => $rol
|
| 81 |
+
]);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Show the form for editing the specified resource.
|
| 86 |
+
*/
|
| 87 |
+
public function edit(string $id)
|
| 88 |
+
{
|
| 89 |
+
$usuarios = Usuario::findOrFail($id);
|
| 90 |
+
$personas = Persona::all();
|
| 91 |
+
$roles = Rol::all();
|
| 92 |
+
return view('admin.usuarios.edit', compact('usuarios', 'personas', 'roles'));
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Update the specified resource in storage.
|
| 97 |
+
*/
|
| 98 |
+
public function update(Request $request, string $id)
|
| 99 |
+
{
|
| 100 |
+
$request->validate([
|
| 101 |
+
'nombre_usuario' => ['required', 'string', 'max:100', Rule::unique('usuarios', 'nombre_usuario')->ignore($id, 'id_usuario')],
|
| 102 |
+
'email' => ['required', 'string', 'max:100', Rule::unique('usuarios', 'email')->ignore($id, 'id_usuario')],
|
| 103 |
+
'id_rol' => 'required|integer',
|
| 104 |
+
'password' => 'nullable|confirmed',
|
| 105 |
+
]);
|
| 106 |
+
|
| 107 |
+
$usuarios = Usuario::findOrFail($id);
|
| 108 |
+
$usuarios->nombre_usuario = $request->nombre_usuario;
|
| 109 |
+
$usuarios->email = $request->email;
|
| 110 |
+
$usuarios->id_rol = $request->id_rol;
|
| 111 |
+
$usuarios->password = Hash::make($request['password']);
|
| 112 |
+
$usuarios->save();
|
| 113 |
+
|
| 114 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario actualizado con éxito.')
|
| 115 |
+
->with('icono', 'success');
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Remove the specified resource from storage.
|
| 120 |
+
*/
|
| 121 |
+
public function destroy(string $id)
|
| 122 |
+
{
|
| 123 |
+
$usuario = Usuario::findOrFail($id);
|
| 124 |
+
$usuario->delete();
|
| 125 |
+
|
| 126 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario eliminado con éxito.')
|
| 127 |
+
->with('icono', 'success');
|
| 128 |
+
}
|
| 129 |
+
}
|
app/app/Http/Kernel.php
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
| 6 |
+
|
| 7 |
+
class Kernel extends HttpKernel
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The application's global HTTP middleware stack.
|
| 11 |
+
*
|
| 12 |
+
* These middleware are run during every request to your application.
|
| 13 |
+
*
|
| 14 |
+
* @var array<int, class-string|string>
|
| 15 |
+
*/
|
| 16 |
+
protected $middleware = [
|
| 17 |
+
// \App\Http\Middleware\TrustHosts::class,
|
| 18 |
+
\App\Http\Middleware\TrustProxies::class,
|
| 19 |
+
\Illuminate\Http\Middleware\HandleCors::class,
|
| 20 |
+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
| 21 |
+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
| 22 |
+
\App\Http\Middleware\TrimStrings::class,
|
| 23 |
+
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
| 24 |
+
];
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* The application's route middleware groups.
|
| 28 |
+
*
|
| 29 |
+
* @var array<string, array<int, class-string|string>>
|
| 30 |
+
*/
|
| 31 |
+
protected $middlewareGroups = [
|
| 32 |
+
'web' => [
|
| 33 |
+
\App\Http\Middleware\EncryptCookies::class,
|
| 34 |
+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
| 35 |
+
\Illuminate\Session\Middleware\StartSession::class,
|
| 36 |
+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
| 37 |
+
\App\Http\Middleware\VerifyCsrfToken::class,
|
| 38 |
+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
| 39 |
+
],
|
| 40 |
+
|
| 41 |
+
'api' => [
|
| 42 |
+
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
| 43 |
+
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
| 44 |
+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
| 45 |
+
],
|
| 46 |
+
];
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* The application's middleware aliases.
|
| 50 |
+
*
|
| 51 |
+
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
| 52 |
+
*
|
| 53 |
+
* @var array<string, class-string|string>
|
| 54 |
+
*/
|
| 55 |
+
protected $middlewareAliases = [
|
| 56 |
+
'auth' => \App\Http\Middleware\Authenticate::class,
|
| 57 |
+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
| 58 |
+
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
| 59 |
+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
| 60 |
+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
| 61 |
+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
| 62 |
+
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
| 63 |
+
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
| 64 |
+
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
| 65 |
+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
| 66 |
+
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
| 67 |
+
'prefecto.access' => \App\Http\Middleware\PrefectoAccessMiddleware::class,
|
| 68 |
+
];
|
| 69 |
+
}
|
app/app/Http/Middleware/Authenticate.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
| 6 |
+
use Illuminate\Http\Request;
|
| 7 |
+
|
| 8 |
+
class Authenticate extends Middleware
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Get the path the user should be redirected to when they are not authenticated.
|
| 12 |
+
*/
|
| 13 |
+
protected function redirectTo(Request $request): ?string
|
| 14 |
+
{
|
| 15 |
+
return $request->expectsJson() ? null : route('login');
|
| 16 |
+
}
|
| 17 |
+
}
|
app/app/Http/Middleware/EncryptCookies.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
| 6 |
+
|
| 7 |
+
class EncryptCookies extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The names of the cookies that should not be encrypted.
|
| 11 |
+
*
|
| 12 |
+
* @var array<int, string>
|
| 13 |
+
*/
|
| 14 |
+
protected $except = [
|
| 15 |
+
//
|
| 16 |
+
];
|
| 17 |
+
}
|
app/app/Http/Middleware/PrefectoAccessMiddleware.php
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Closure;
|
| 6 |
+
use Illuminate\Http\Request;
|
| 7 |
+
use Illuminate\Support\Facades\Auth;
|
| 8 |
+
use Symfony\Component\HttpFoundation\Response;
|
| 9 |
+
use App\Models\GrupoPrefecto;
|
| 10 |
+
use App\Models\Grupo;
|
| 11 |
+
|
| 12 |
+
class PrefectoAccessMiddleware
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* Handle an incoming request.
|
| 16 |
+
*
|
| 17 |
+
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
| 18 |
+
*/
|
| 19 |
+
public function handle(Request $request, Closure $next): Response
|
| 20 |
+
{
|
| 21 |
+
|
| 22 |
+
if (!Auth::check()) {
|
| 23 |
+
return redirect()->route('login')->with('error', 'Debes iniciar sesión.');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
$usuario = auth()->user();
|
| 27 |
+
$persona = optional($usuario->persona);
|
| 28 |
+
$rolNombre = $usuario->rol->nombre_rol;
|
| 29 |
+
|
| 30 |
+
$rolesPermitidos = ['Administrador', 'Coordinador'];
|
| 31 |
+
|
| 32 |
+
if (in_array($rolNombre, $rolesPermitidos)) {
|
| 33 |
+
return $next($request);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$asignaciones = GrupoPrefecto::where('persona_id', $persona->id_persona)->get();
|
| 37 |
+
|
| 38 |
+
if ($asignaciones->isEmpty()) {
|
| 39 |
+
return redirect('/')->with('error', 'No tienes grupos asignados.');
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
$gruposAsignados = $asignaciones->pluck('id_grupo');
|
| 43 |
+
|
| 44 |
+
$grado = $request->route('grado');
|
| 45 |
+
$grupo = $request->route('grupo');
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
$grupoEncontrado = Grupo::where('grado', $grado)
|
| 49 |
+
->where('grupo', $grupo)
|
| 50 |
+
->first();
|
| 51 |
+
|
| 52 |
+
if (!$grupoEncontrado) {
|
| 53 |
+
abort(403, 'Grupo no encontrado.');
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
if ($gruposAsignados->contains((int) $grupoEncontrado->id_grupo)) {
|
| 57 |
+
return $next($request);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
abort(403, 'Acceso denegado a este grupo.');
|
| 61 |
+
|
| 62 |
+
if ($request->route('justificante')) {
|
| 63 |
+
$justificantesId = $request->route('justificante');
|
| 64 |
+
$justificantes = Justificante::find($justificantesId);
|
| 65 |
+
|
| 66 |
+
if (!$justificantes) {
|
| 67 |
+
abort(403, 'Justificante no encontrado.');
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if (!in_array($justificantes->alumno->id_grupo, $gruposAsignados)) {
|
| 71 |
+
abort(403, 'Acceso denegado. No puedes ver este justificante.');
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if ($request->route('reporte')) {
|
| 76 |
+
$reportesId = $request->route('reporte');
|
| 77 |
+
$reportes = Reporte::find($reportesId);
|
| 78 |
+
|
| 79 |
+
if (!$reportes) {
|
| 80 |
+
abort(403, 'reporte no encontrado.');
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if (!in_array($reportes->alumno->id_grupo, $gruposAsignados)) {
|
| 84 |
+
abort(403, 'Acceso denegado. No puedes ver este reporte.');
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
if ($request->route('aviso')) {
|
| 89 |
+
$avisosId = $request->route('aviso');
|
| 90 |
+
$avisos = Aviso::find($avisosId);
|
| 91 |
+
|
| 92 |
+
if (!$avisos) {
|
| 93 |
+
abort(403, 'aviso no encontrado.');
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
if (!in_array($avisos->alumno->id_grupo, $gruposAsignados)) {
|
| 97 |
+
abort(403, 'Acceso denegado. No puedes ver este aviso.');
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
}
|
| 102 |
+
}
|
app/app/Http/Middleware/PreventRequestsDuringMaintenance.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
| 6 |
+
|
| 7 |
+
class PreventRequestsDuringMaintenance extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The URIs that should be reachable while maintenance mode is enabled.
|
| 11 |
+
*
|
| 12 |
+
* @var array<int, string>
|
| 13 |
+
*/
|
| 14 |
+
protected $except = [
|
| 15 |
+
//
|
| 16 |
+
];
|
| 17 |
+
}
|
app/app/Http/Middleware/RedirectIfAuthenticated.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use App\Providers\RouteServiceProvider;
|
| 6 |
+
use Closure;
|
| 7 |
+
use Illuminate\Http\Request;
|
| 8 |
+
use Illuminate\Support\Facades\Auth;
|
| 9 |
+
use Symfony\Component\HttpFoundation\Response;
|
| 10 |
+
|
| 11 |
+
class RedirectIfAuthenticated
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Handle an incoming request.
|
| 15 |
+
*
|
| 16 |
+
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
| 17 |
+
*/
|
| 18 |
+
public function handle(Request $request, Closure $next, string ...$guards): Response
|
| 19 |
+
{
|
| 20 |
+
$guards = empty($guards) ? [null] : $guards;
|
| 21 |
+
|
| 22 |
+
foreach ($guards as $guard) {
|
| 23 |
+
if (Auth::guard($guard)->check()) {
|
| 24 |
+
return redirect(RouteServiceProvider::HOME);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return $next($request);
|
| 29 |
+
}
|
| 30 |
+
}
|
app/app/Http/Middleware/TrimStrings.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
| 6 |
+
|
| 7 |
+
class TrimStrings extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The names of the attributes that should not be trimmed.
|
| 11 |
+
*
|
| 12 |
+
* @var array<int, string>
|
| 13 |
+
*/
|
| 14 |
+
protected $except = [
|
| 15 |
+
'current_password',
|
| 16 |
+
'password',
|
| 17 |
+
'password_confirmation',
|
| 18 |
+
];
|
| 19 |
+
}
|
app/app/Http/Middleware/TrustHosts.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
| 6 |
+
|
| 7 |
+
class TrustHosts extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* Get the host patterns that should be trusted.
|
| 11 |
+
*
|
| 12 |
+
* @return array<int, string|null>
|
| 13 |
+
*/
|
| 14 |
+
public function hosts(): array
|
| 15 |
+
{
|
| 16 |
+
return [
|
| 17 |
+
$this->allSubdomainsOfApplicationUrl(),
|
| 18 |
+
];
|
| 19 |
+
}
|
| 20 |
+
}
|
app/app/Http/Middleware/TrustProxies.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
| 6 |
+
use Illuminate\Http\Request;
|
| 7 |
+
|
| 8 |
+
class TrustProxies extends Middleware
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* The trusted proxies for this application.
|
| 12 |
+
*
|
| 13 |
+
* @var array<int, string>|string|null
|
| 14 |
+
*/
|
| 15 |
+
protected $proxies;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* The headers that should be used to detect proxies.
|
| 19 |
+
*
|
| 20 |
+
* @var int
|
| 21 |
+
*/
|
| 22 |
+
protected $headers =
|
| 23 |
+
Request::HEADER_X_FORWARDED_FOR |
|
| 24 |
+
Request::HEADER_X_FORWARDED_HOST |
|
| 25 |
+
Request::HEADER_X_FORWARDED_PORT |
|
| 26 |
+
Request::HEADER_X_FORWARDED_PROTO |
|
| 27 |
+
Request::HEADER_X_FORWARDED_AWS_ELB;
|
| 28 |
+
}
|
app/app/Http/Middleware/ValidateSignature.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
| 6 |
+
|
| 7 |
+
class ValidateSignature extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The names of the query string parameters that should be ignored.
|
| 11 |
+
*
|
| 12 |
+
* @var array<int, string>
|
| 13 |
+
*/
|
| 14 |
+
protected $except = [
|
| 15 |
+
// 'fbclid',
|
| 16 |
+
// 'utm_campaign',
|
| 17 |
+
// 'utm_content',
|
| 18 |
+
// 'utm_medium',
|
| 19 |
+
// 'utm_source',
|
| 20 |
+
// 'utm_term',
|
| 21 |
+
];
|
| 22 |
+
}
|
app/app/Http/Middleware/VerifyCsrfToken.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Middleware;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
| 6 |
+
|
| 7 |
+
class VerifyCsrfToken extends Middleware
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* The URIs that should be excluded from CSRF verification.
|
| 11 |
+
*
|
| 12 |
+
* @var array<int, string>
|
| 13 |
+
*/
|
| 14 |
+
protected $except = [
|
| 15 |
+
//
|
| 16 |
+
];
|
| 17 |
+
}
|
app/app/Models/Alumno.php
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
use Illuminate\Database\Eloquent\Relations\HasOne;
|
| 8 |
+
class Alumno extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'alumnos';
|
| 13 |
+
protected $primaryKey = 'id_alumno';
|
| 14 |
+
protected $fillable = [
|
| 15 |
+
'persona_id',
|
| 16 |
+
'numero_control',
|
| 17 |
+
'id_tutor',
|
| 18 |
+
'id_grupo',
|
| 19 |
+
'curp',
|
| 20 |
+
'image_path',
|
| 21 |
+
'promedio_general'
|
| 22 |
+
];
|
| 23 |
+
|
| 24 |
+
protected $attributes = [
|
| 25 |
+
'promedio_general' => 0.0
|
| 26 |
+
];
|
| 27 |
+
|
| 28 |
+
//public function todos()
|
| 29 |
+
//{
|
| 30 |
+
// DB::table('alumnos')->insert
|
| 31 |
+
//}
|
| 32 |
+
|
| 33 |
+
public function persona()//: HasOne
|
| 34 |
+
{
|
| 35 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 36 |
+
//return $this->hasOne(Persona::Class);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function tutor()
|
| 40 |
+
{
|
| 41 |
+
return $this->belongsTo(Tutor::class, 'id_tutor');
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
public function grupo()
|
| 45 |
+
{
|
| 46 |
+
return $this->belongsTo(Grupo::class, 'id_grupo');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function calificaciones()
|
| 50 |
+
{
|
| 51 |
+
return $this->hasMany(Calificacion::class, 'id_alumno');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public function reportes()
|
| 55 |
+
{
|
| 56 |
+
return $this->hasMany(Reporte::class, 'id_alumno');
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function justificantes()
|
| 60 |
+
{
|
| 61 |
+
return $this->hasMany(Justificante::class, 'id_alumno');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function avisos()
|
| 65 |
+
{
|
| 66 |
+
return $this->hasMany(Aviso::class, 'id_alumno');
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public function grupo_grado()
|
| 70 |
+
{
|
| 71 |
+
if ($this->grupo) {
|
| 72 |
+
return $this->grupo->grado . '°' . $this->grupo->grupo;
|
| 73 |
+
}
|
| 74 |
+
return 'Grado no asignado';
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
}
|
app/app/Models/Aviso.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Aviso extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'avisos';
|
| 13 |
+
protected $primaryKey = 'id_aviso';
|
| 14 |
+
|
| 15 |
+
public function alumno()
|
| 16 |
+
{
|
| 17 |
+
return $this->belongsTo(Alumno::class, 'id_alumno');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function persona()
|
| 21 |
+
{
|
| 22 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function creador()
|
| 26 |
+
{
|
| 27 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function elaborador()
|
| 31 |
+
{
|
| 32 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
}
|
app/app/Models/Calificacion.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Calificacion extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'calificaciones';
|
| 13 |
+
protected $primaryKey = 'id_calificacion';
|
| 14 |
+
protected $fillable = ['id_alumno', 'id_materia', 'calificacion', 'trimestre'];
|
| 15 |
+
|
| 16 |
+
public function alumno()
|
| 17 |
+
{
|
| 18 |
+
return $this->belongsTo(Alumno::class, 'id_alumno');
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function materia()
|
| 22 |
+
{
|
| 23 |
+
return $this->belongsTo(Materia::class, 'id_materia');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
}
|
app/app/Models/Grupo.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Grupo extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'grupos';
|
| 13 |
+
protected $primaryKey = 'id_grupo';
|
| 14 |
+
protected $fillable = ['grado', 'grupo', 'id_materia'];
|
| 15 |
+
|
| 16 |
+
public function alumnos()
|
| 17 |
+
{
|
| 18 |
+
return $this->hasMany(Alumno::class, 'id_grupo');
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function persona()
|
| 22 |
+
{
|
| 23 |
+
return $this->hasMany(Persona::class, 'persona_id');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
public function gruposPrefecto()
|
| 27 |
+
{
|
| 28 |
+
return $this->hasMany(GrupoPrefecto::class, 'id_grupo');
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public function grupo_grado()
|
| 32 |
+
{
|
| 33 |
+
return $this->grado . '°' . $this->grupo;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public function usuario()
|
| 37 |
+
{
|
| 38 |
+
return $this->belongsToMany(Usuario::class, 'id_usuario');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function materia()
|
| 42 |
+
{
|
| 43 |
+
return $this->belongsTo(Materia::class, 'id_materia');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
}
|
app/app/Models/GrupoPrefecto.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class GrupoPrefecto extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'grupos_prefectos';
|
| 13 |
+
protected $primaryKey = 'id_grupo_prefecto';
|
| 14 |
+
|
| 15 |
+
public function grupo()
|
| 16 |
+
{
|
| 17 |
+
return $this->belongsTo(Grupo::class, 'id_grupo');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function persona()
|
| 21 |
+
{
|
| 22 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function periodo()
|
| 26 |
+
{
|
| 27 |
+
return $this->belongsTo(Periodo::class, 'id_periodo');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
}
|
app/app/Models/Justificante.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Justificante extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'justificantes';
|
| 13 |
+
protected $primaryKey = 'id_justificante';
|
| 14 |
+
|
| 15 |
+
public function alumno()
|
| 16 |
+
{
|
| 17 |
+
return $this->belongsTo(Alumno::class, 'id_alumno');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function persona()
|
| 21 |
+
{
|
| 22 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function creador()
|
| 26 |
+
{
|
| 27 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function elaborador()
|
| 31 |
+
{
|
| 32 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
}
|
app/app/Models/JustificanteMaestro.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class JustificanteMaestro extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'justificantes_maestros';
|
| 13 |
+
protected $primaryKey = 'id_justificantes';
|
| 14 |
+
|
| 15 |
+
public function maestro()
|
| 16 |
+
{
|
| 17 |
+
return $this->belongsTo(Maestro::class, 'id_maestro');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function persona()
|
| 21 |
+
{
|
| 22 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function periodo()
|
| 26 |
+
{
|
| 27 |
+
return $this->belongsTo(Periodo::class, 'id_periodo', 'id_periodo');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function elaborador()
|
| 31 |
+
{
|
| 32 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 33 |
+
}
|
| 34 |
+
}
|
app/app/Models/Maestro.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Maestro extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'maestros';
|
| 13 |
+
protected $primaryKey = 'id_maestro';
|
| 14 |
+
protected $fillable = ['persona_id'];
|
| 15 |
+
|
| 16 |
+
public function persona()
|
| 17 |
+
{
|
| 18 |
+
return $this->belongsTo(Persona::class, 'persona_id', 'id_persona');
|
| 19 |
+
}
|
| 20 |
+
}
|
app/app/Models/Materia.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Models;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
| 6 |
+
use Illuminate\Database\Eloquent\Model;
|
| 7 |
+
|
| 8 |
+
class Materia extends Model
|
| 9 |
+
{
|
| 10 |
+
use HasFactory;
|
| 11 |
+
|
| 12 |
+
protected $table = 'materias';
|
| 13 |
+
protected $primaryKey = 'id_materia';
|
| 14 |
+
|
| 15 |
+
public function calificaciones()
|
| 16 |
+
{
|
| 17 |
+
return $this->hasMany(Calificacion::class, 'id_materia');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function grupos()
|
| 21 |
+
{
|
| 22 |
+
return $this->hasMany(Grupo::class, 'id_materia');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|