projecto maestria
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +5 -0
- .gitconfig +2 -0
- .gitignore +54 -0
- .vscode/extensions.json +5 -0
- Dockerfile +139 -0
- License +70 -0
- app/.env.example +59 -0
- app/.gitignore +49 -0
- app/.gitkeep +0 -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 +290 -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 +119 -0
- app/app/Http/Controllers/GrupoPrefectoController.php +129 -0
- app/app/Http/Controllers/GruposAlumnosController.php +66 -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 +94 -0
- app/app/Http/Controllers/ReporteController.php +250 -0
- app/app/Http/Controllers/RolController.php +76 -0
- app/app/Http/Controllers/SistemaController.php +50 -0
- app/app/Http/Controllers/TutorController.php +128 -0
- app/app/Http/Controllers/UsuarioController.php +128 -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 +72 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.eot filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.ttf filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.woff filter=lfs diff=lfs merge=lfs -text
|
.gitconfig
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[safe]
|
| 2 |
+
directory = C:/Users/WDAGUtilityAccount/Desktop/exchage/hugging-face/control
|
.gitignore
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
composer.phar
|
| 2 |
+
/vendor/
|
| 3 |
+
#app/vendor
|
| 4 |
+
|
| 5 |
+
# composer.lock
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
node_modules/
|
| 9 |
+
app/node_modules
|
| 10 |
+
npm-debug.log
|
| 11 |
+
yarn-error.log
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
bootstrap/compiled.php
|
| 15 |
+
#app/storage/
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
public/storage
|
| 19 |
+
public/hot
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
public_html/storage
|
| 23 |
+
public_html/hot
|
| 24 |
+
|
| 25 |
+
storage/*.key
|
| 26 |
+
.env
|
| 27 |
+
Homestead.yaml
|
| 28 |
+
Homestead.json
|
| 29 |
+
/.vagrant
|
| 30 |
+
.phpunit.result.cache
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
.vscode/*
|
| 34 |
+
!.vscode/settings.json
|
| 35 |
+
!.vscode/tasks.json
|
| 36 |
+
!.vscode/launch.json
|
| 37 |
+
!.vscode/extensions.json
|
| 38 |
+
!.vscode/*.code-snippets
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
.history/
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
*.vsix
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
.history
|
| 48 |
+
.ionide
|
| 49 |
+
.vscode/settings.json
|
| 50 |
+
use cases general.puml
|
| 51 |
+
model.dbml
|
| 52 |
+
new.dbml
|
| 53 |
+
nuevo.dbml
|
| 54 |
+
**.mermaid
|
.vscode/extensions.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"recommendations": [
|
| 3 |
+
"bocovo.dbml-erd-visualizer"
|
| 4 |
+
]
|
| 5 |
+
}
|
Dockerfile
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ubuntu:24.04
|
| 2 |
+
RUN apt update -y
|
| 3 |
+
RUN apt upgrade -y
|
| 4 |
+
RUN apt install -y php curl unzip wget xz-utils php-xml php-curl php-mysql php-pdo php-mbstring
|
| 5 |
+
RUN rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
USER ubuntu
|
| 8 |
+
ENV HOME=/home/ubuntu \
|
| 9 |
+
PATH=/home/ubuntu/.local/bin:$PATH
|
| 10 |
+
WORKDIR $HOME
|
| 11 |
+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
| 12 |
+
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
| 13 |
+
RUN php composer-setup.php
|
| 14 |
+
RUN php -r "unlink('composer-setup.php');"
|
| 15 |
+
USER root
|
| 16 |
+
RUN mv composer.phar /usr/local/bin/composer
|
| 17 |
+
USER ubuntu
|
| 18 |
+
|
| 19 |
+
RUN wget https://nodejs.org/dist/v20.18.1/node-v20.18.1-linux-x64.tar.xz
|
| 20 |
+
|
| 21 |
+
RUN chmod 777 ./node-v20.18.1-linux-x64.tar.xz
|
| 22 |
+
|
| 23 |
+
RUN tar -xf './node-v20.18.1-linux-x64.tar.xz'
|
| 24 |
+
|
| 25 |
+
USER root
|
| 26 |
+
|
| 27 |
+
RUN cp -r $HOME/node-v20.18.1-linux-x64/bin $HOME/node-v20.18.1-linux-x64/include $HOME/node-v20.18.1-linux-x64/lib $HOME/node-v20.18.1-linux-x64/share /usr/
|
| 28 |
+
|
| 29 |
+
USER ubuntu
|
| 30 |
+
RUN mkdir example-app
|
| 31 |
+
|
| 32 |
+
WORKDIR $HOME/example-app
|
| 33 |
+
COPY --chown=ubuntu app/ ./
|
| 34 |
+
|
| 35 |
+
RUN chmod 777 -R $HOME/example-app
|
| 36 |
+
|
| 37 |
+
RUN composer install
|
| 38 |
+
|
| 39 |
+
RUN cp $HOME/example-app/.env.example $HOME/example-app/.env
|
| 40 |
+
|
| 41 |
+
RUN php artisan key:generate
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
CMD \
|
| 45 |
+
sed -i "s|\$DB-DATABASE|$DB_DATABASE|" .env && \
|
| 46 |
+
sed -i "s|\$DB-USERNAME|$DB_USERNAME|" .env && \
|
| 47 |
+
sed -i "s|\$DB-HOST|$DB_HOST|" .env && \
|
| 48 |
+
sed -i "s|\$DB-PORT|$DB_PORT|" .env && \
|
| 49 |
+
sed -i "s|\$DB-PASSWORD|$DB_PASSWORD|" .env && \
|
| 50 |
+
# composer clear-cache; \
|
| 51 |
+
# composer install; \
|
| 52 |
+
chown -R ubuntu:ubuntu $HOME/example-app; \
|
| 53 |
+
php artisan storage:link; \
|
| 54 |
+
chmod 777 -R $HOME/example-app; \
|
| 55 |
+
#####php artisan migrate:refresh;\
|
| 56 |
+
php artisan migrate; \
|
| 57 |
+
#####php artisan migrate:status; \
|
| 58 |
+
#####echo ========== factory PersonaSeeder ============; \
|
| 59 |
+
#####php artisan db:seed --class=PersonaSeeder;\
|
| 60 |
+
#####echo ========== factory RolSeeder ============; \
|
| 61 |
+
#####php artisan db:seed --class=RolSeeder;\
|
| 62 |
+
#####echo ========== factory DefaultUsuarioSeeder ============; \
|
| 63 |
+
#####php artisan db:seed --class=DefaultUsuarioSeeder;\
|
| 64 |
+
php artisan serve --host=0.0.0.0 --port=7860; : > /dev/null 2>&1; \
|
| 65 |
+
php -S 0.0.0.0:7860; \
|
| 66 |
+
tail -F keep.run
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
#######################FROM ubuntu:24.04
|
| 71 |
+
#######################RUN apt update -y
|
| 72 |
+
#######################RUN apt upgrade -y
|
| 73 |
+
#######################RUN apt install -y php curl unzip wget xz-utils php-xml php-curl php-mysql php-pdo php-mbstring
|
| 74 |
+
#######################RUN rm -rf /var/lib/apt/lists/*
|
| 75 |
+
#######################
|
| 76 |
+
#######################USER ubuntu
|
| 77 |
+
#######################ENV HOME=/home/ubuntu \
|
| 78 |
+
####################### PATH=/home/ubuntu/.local/bin:$PATH
|
| 79 |
+
#######################WORKDIR $HOME
|
| 80 |
+
#######################RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
| 81 |
+
#######################RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
| 82 |
+
#######################RUN php composer-setup.php
|
| 83 |
+
#######################RUN php -r "unlink('composer-setup.php');"
|
| 84 |
+
#######################USER root
|
| 85 |
+
#######################RUN mv composer.phar /usr/local/bin/composer
|
| 86 |
+
#######################USER ubuntu
|
| 87 |
+
#######################
|
| 88 |
+
#######################RUN wget https://nodejs.org/dist/v20.18.1/node-v20.18.1-linux-x64.tar.xz
|
| 89 |
+
#######################
|
| 90 |
+
#######################RUN chmod 777 ./node-v20.18.1-linux-x64.tar.xz
|
| 91 |
+
#######################
|
| 92 |
+
#######################RUN tar -xf './node-v20.18.1-linux-x64.tar.xz'
|
| 93 |
+
#######################
|
| 94 |
+
#######################USER root
|
| 95 |
+
#######################
|
| 96 |
+
#######################RUN cp -r $HOME/node-v20.18.1-linux-x64/bin $HOME/node-v20.18.1-linux-x64/include $HOME/node-v20.18.1-linux-x64/lib $HOME/node-v20.18.1-linux-x64/share /usr/
|
| 97 |
+
#######################
|
| 98 |
+
#######################USER ubuntu
|
| 99 |
+
#######################RUN mkdir example-app
|
| 100 |
+
#######################
|
| 101 |
+
#######################WORKDIR $HOME/example-app
|
| 102 |
+
#######################COPY --chown=ubuntu app/ ./
|
| 103 |
+
#######################
|
| 104 |
+
#######################RUN chmod 777 -R $HOME/example-app
|
| 105 |
+
##########################RUN composer install
|
| 106 |
+
##########################RUN composer clear-cache
|
| 107 |
+
##########################RUN php artisan cache:clear
|
| 108 |
+
##########################RUN php artisan config:clear
|
| 109 |
+
##########################RUN php artisan config:cache
|
| 110 |
+
##########################RUN composer clear-cache
|
| 111 |
+
#######################RUN composer install
|
| 112 |
+
##########################RUN npm install
|
| 113 |
+
#######################RUN cp $HOME/example-app/.env.example $HOME/example-app/.env
|
| 114 |
+
#######################
|
| 115 |
+
#######################RUN php artisan key:generate
|
| 116 |
+
########################RUN mkdir -p $HOME/example-app/public/storage/images
|
| 117 |
+
#######################
|
| 118 |
+
##########################RUN chmod 777 -R $HOME/example-app
|
| 119 |
+
##########################RUN chown -R ubuntu:ubuntu $HOME/example-app
|
| 120 |
+
#######################
|
| 121 |
+
#######################CMD \
|
| 122 |
+
#######################ls && \
|
| 123 |
+
#######################pwd && \
|
| 124 |
+
#######################ls storage -la && \
|
| 125 |
+
#######################sed -i "s|\$DB-DATABASE|$DB_DATABASE|" .env && \
|
| 126 |
+
#######################sed -i "s|\$DB-USERNAME|$DB_USERNAME|" .env && \
|
| 127 |
+
#######################sed -i "s|\$DB-HOST|$DB_HOST|" .env && \
|
| 128 |
+
#######################sed -i "s|\$DB-PORT|$DB_PORT|" .env && \
|
| 129 |
+
#######################sed -i "s|\$DB-PASSWORD|$DB_PASSWORD|" .env && \
|
| 130 |
+
#######################composer clear-cache; \
|
| 131 |
+
#######################composer install; \
|
| 132 |
+
#######################chown -R ubuntu:ubuntu $HOME/example-app; \
|
| 133 |
+
#######################php artisan storage:link; \
|
| 134 |
+
#######################chmod 777 -R $HOME/example-app; \
|
| 135 |
+
#######################php artisan migrate; \
|
| 136 |
+
#######################php artisan migrate:status; \
|
| 137 |
+
#######################php artisan serve --host=0.0.0.0 --port=7860; \
|
| 138 |
+
#######################php -S 0.0.0.0:7860; \
|
| 139 |
+
#######################tail -F keep.run
|
License
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## **Proprietary Software License Agreement (Worldwide Use)**
|
| 2 |
+
|
| 3 |
+
**Effective Date:** 05/05/2025
|
| 4 |
+
**Licensor:** AILV
|
| 5 |
+
**Jurisdiction:** Worldwide
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
### **1. Ownership and Intellectual Property Rights**
|
| 10 |
+
|
| 11 |
+
This software application (the “Software”), including all associated source code, object code, design, data, content, interfaces, documentation, and trademarks, is the sole and exclusive property of the Licensor. It is protected under international intellectual property laws, including but not limited to copyright, trademark, and trade secret laws.
|
| 12 |
+
|
| 13 |
+
No rights or licenses are granted except as expressly stated in this Agreement. All rights not expressly granted are reserved by the Licensor.
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
### **2. Restrictions on Use**
|
| 18 |
+
|
| 19 |
+
You may **not**, under any circumstances and in any jurisdiction, do any of the following without prior written permission from the Licensor:
|
| 20 |
+
|
| 21 |
+
* Copy, reproduce, republish, upload, post, transmit, or distribute any part of the Software;
|
| 22 |
+
* Modify, alter, adapt, translate, or create derivative works based on the Software;
|
| 23 |
+
* Sell, rent, lease, sublicense, distribute, or otherwise commercially exploit the Software or any part thereof;
|
| 24 |
+
* Decompile, disassemble, reverse engineer, or otherwise attempt to extract source code or trade secrets from the Software;
|
| 25 |
+
* Use the Software or any part of it, including data or trademarks, for any unauthorized purpose;
|
| 26 |
+
* Remove, obscure, or alter any copyright, trademark, or other proprietary notices.
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
### **3. Trademarks**
|
| 31 |
+
|
| 32 |
+
All logos, names, brand identifiers, and other trademarks related to the Software are the exclusive property of the Licensor. Unauthorized use of these marks is strictly prohibited and constitutes a violation of intellectual property law.
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
### **4. No Transfer of Rights**
|
| 37 |
+
|
| 38 |
+
This Agreement does not constitute a sale and does not convey any rights of ownership in the Software. You are granted no title or ownership rights in the Software or any component thereof.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
### **5. Termination**
|
| 43 |
+
|
| 44 |
+
This license is effective until terminated. The Licensor may terminate this Agreement at any time without notice if you breach any term herein. Upon termination, you must immediately cease all use of the Software and destroy all copies.
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
### **6. Disclaimer of Warranties**
|
| 49 |
+
|
| 50 |
+
The Software is provided “AS IS” without any representations or warranties, express or implied. The Licensor disclaims all warranties, including merchantability, fitness for a particular purpose, non-infringement, and availability.
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
### **7. Limitation of Liability**
|
| 55 |
+
|
| 56 |
+
To the maximum extent permitted by applicable law, in no event shall the Licensor be liable for any indirect, incidental, consequential, or special damages, including loss of profits, data, or use, arising out of or related to the use of the Software.
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
### **8. Governing Law and Jurisdiction**
|
| 61 |
+
|
| 62 |
+
This Agreement shall be governed and enforced in accordance with the laws of a neutral international jurisdiction, specifically **the United Nations Convention on Contracts for the International Sale of Goods (CISG)**, where applicable. In all other cases, this Agreement shall be governed by the laws of \[Insert Preferred Country or Jurisdiction, e.g., Switzerland or Singapore], without regard to its conflict of law provisions.
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
### **9. Entire Agreement**
|
| 67 |
+
|
| 68 |
+
This Agreement constitutes the complete and exclusive understanding between the parties and supersedes all prior or contemporaneous agreements, communications, and understandings, whether oral or written.
|
| 69 |
+
|
| 70 |
+
---
|
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/.gitkeep
ADDED
|
File without changes
|
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,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
public function index(){
|
| 20 |
+
$usuario = Auth::user();
|
| 21 |
+
$persona = $usuario->persona;
|
| 22 |
+
$usuarioRol = $usuario->id_rol;
|
| 23 |
+
|
| 24 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 25 |
+
$alumnos = Alumno::with('persona', 'grupo')->get();
|
| 26 |
+
return view('admin.alumnos.index', compact('alumnos'));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 30 |
+
->pluck('id_grupo')
|
| 31 |
+
->toArray();
|
| 32 |
+
|
| 33 |
+
//dd($gruposAsignados);
|
| 34 |
+
|
| 35 |
+
if (empty($gruposAsignados)) {
|
| 36 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)
|
| 40 |
+
->with('persona', 'grupo')
|
| 41 |
+
->get();
|
| 42 |
+
|
| 43 |
+
//dd($alumnos);
|
| 44 |
+
|
| 45 |
+
return view('admin.alumnos.index', compact('alumnos'));
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
public function porGradoYGrupo($grado, $grupo){
|
| 50 |
+
$usuario = Auth::user();
|
| 51 |
+
$persona = optional($usuario->persona);
|
| 52 |
+
$personaId = $persona->id_persona ?? null;
|
| 53 |
+
|
| 54 |
+
if (!$personaId) {
|
| 55 |
+
abort(403, 'No se encontró la información personal del usuario.');
|
| 56 |
+
}
|
| 57 |
+
$usuarioRol = $usuario->id_rol;
|
| 58 |
+
|
| 59 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 60 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 61 |
+
->pluck('id_grupo')
|
| 62 |
+
->toArray();
|
| 63 |
+
|
| 64 |
+
$grupoEncontrado = Grupo::where('grado', $grado)
|
| 65 |
+
->where('grupo', $grupo)
|
| 66 |
+
->first();
|
| 67 |
+
|
| 68 |
+
if (!$grupoEncontrado || !in_array($grupoEncontrado->id_grupo, $gruposAsignados)) {
|
| 69 |
+
abort(403, 'Acceso denegado a este grupo.');
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
$grupoSeleccionado = Grupo::with('alumnos.persona', 'alumnos.tutor.persona')
|
| 74 |
+
->where('grado', $grado)
|
| 75 |
+
->where('grupo', $grupo)
|
| 76 |
+
->first();
|
| 77 |
+
|
| 78 |
+
return view('admin.alumnos.grupo', compact('grupoSeleccionado'));
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
public function promocionarAlumnos(){
|
| 82 |
+
$alumnos = Alumno::all();
|
| 83 |
+
|
| 84 |
+
foreach ($alumnos as $alumno) {
|
| 85 |
+
|
| 86 |
+
$promedio = Calificacion::where('id_alumno', $alumno->id_alumno)->avg('calificacion');
|
| 87 |
+
$alumno->promedio_general = $promedio;
|
| 88 |
+
$alumno->save();
|
| 89 |
+
|
| 90 |
+
$grupoActual = Grupo::find($alumno->id_grupo);
|
| 91 |
+
|
| 92 |
+
if (!$grupoActual) {
|
| 93 |
+
continue;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
if ($grupoActual->grado == 3) {
|
| 97 |
+
|
| 98 |
+
$this->eliminarRegistrosAlumno($alumno);
|
| 99 |
+
} else {
|
| 100 |
+
|
| 101 |
+
if ($promedio >= 6.0) {
|
| 102 |
+
|
| 103 |
+
$this->eliminarCalificacionesGradoAnterior($alumno, $grupoActual->grado);
|
| 104 |
+
|
| 105 |
+
$nuevoGrupoId = $this->promocionarGrupo($alumno->id_grupo);
|
| 106 |
+
|
| 107 |
+
if ($nuevoGrupoId) {
|
| 108 |
+
$alumno->id_grupo = $nuevoGrupoId;
|
| 109 |
+
$alumno->save();
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
return redirect()->route('alumnos.index')
|
| 116 |
+
->with('mensaje', 'Promoción de alumnos realizada con éxito.')
|
| 117 |
+
->with('icono', 'success');
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
private function eliminarCalificacionesGradoAnterior($alumno, $gradoActual){
|
| 121 |
+
if ($gradoActual <= 1) {
|
| 122 |
+
return;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
$gradoAnterior = $gradoActual - 1;
|
| 126 |
+
|
| 127 |
+
$materias = Materia::where('grado', $gradoAnterior)->pluck('id_materia');
|
| 128 |
+
|
| 129 |
+
if ($materias->isNotEmpty()) {
|
| 130 |
+
Calificacion::where('id_alumno', $alumno->id_alumno)
|
| 131 |
+
->whereIn('id_materia', $materias)
|
| 132 |
+
->delete();
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
private function promocionarGrupo($idGrupo){
|
| 137 |
+
$grupoActual = Grupo::find($idGrupo);
|
| 138 |
+
|
| 139 |
+
if (!$grupoActual) {
|
| 140 |
+
return null;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
$siguienteGrupo = Grupo::where('grado', $grupoActual->grado + 1)
|
| 144 |
+
->where('grupo', $grupoActual->grupo)
|
| 145 |
+
->first();
|
| 146 |
+
|
| 147 |
+
return $siguienteGrupo ? $siguienteGrupo->id_grupo : null;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
private function eliminarRegistrosAlumno($alumno){
|
| 151 |
+
$idPersonaTutor = Tutor::where('id_tutor', $alumno->id_tutor)->value('persona_id');
|
| 152 |
+
|
| 153 |
+
Tutor::where('id_tutor', $alumno->id_tutor)->delete();
|
| 154 |
+
Calificacion::where('id_alumno', $alumno->id_alumno)->delete();
|
| 155 |
+
$alumno->delete();
|
| 156 |
+
|
| 157 |
+
if ($idPersonaTutor) {
|
| 158 |
+
Persona::where('id_persona', $idPersonaTutor)->delete();
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
Persona::where('id_persona', $alumno->persona_id)->delete();
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Show the form for creating a new resource.
|
| 166 |
+
*/
|
| 167 |
+
public function create(){
|
| 168 |
+
$personas = Persona::all();
|
| 169 |
+
$tutores = Tutor::all();
|
| 170 |
+
$grupos = Grupo::all();
|
| 171 |
+
return view('admin.alumnos.create', compact('personas', 'tutores', 'grupos'));
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* Store a newly created resource in storage.
|
| 176 |
+
*/
|
| 177 |
+
public function store(Request $request){
|
| 178 |
+
//dd($request->all());
|
| 179 |
+
$request->validate([
|
| 180 |
+
'persona_id' => 'required|string|max:100',
|
| 181 |
+
'numero_control' => 'required|string|max:100|unique:alumnos,numero_control',
|
| 182 |
+
'id_tutor' => 'required|string|max:100',
|
| 183 |
+
'id_grupo' => 'required|string|max:100',
|
| 184 |
+
'curp' => 'required|string|max:100',
|
| 185 |
+
'image_path' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048'
|
| 186 |
+
]);
|
| 187 |
+
|
| 188 |
+
if ($request->hasFile('image')) {
|
| 189 |
+
$path = $request->file('image')->store('images', 'public');
|
| 190 |
+
|
| 191 |
+
//$grupo = Grupo::find($request->id_grupo);
|
| 192 |
+
|
| 193 |
+
$alumnos = new Alumno();
|
| 194 |
+
$alumnos->persona_id = $request->persona_id;
|
| 195 |
+
$alumnos->numero_control = $request->numero_control;
|
| 196 |
+
$alumnos->id_tutor = $request->id_tutor;
|
| 197 |
+
$alumnos->id_grupo = $request->id_grupo;
|
| 198 |
+
$alumnos->curp = $request->curp;
|
| 199 |
+
$alumnos->image_path = $path;
|
| 200 |
+
//dd($alumnos);
|
| 201 |
+
$alumnos->save();
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
return redirect()->route('alumnos.index')->with('mensaje', 'Se registro el alumno de la manera correcta')
|
| 205 |
+
->with('icono', 'success');
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
public function show(string $id){
|
| 209 |
+
$alumnos = Alumno::with('persona', 'tutor', 'grupo')->findOrFail($id);
|
| 210 |
+
$persona_id = $alumnos->persona_id;
|
| 211 |
+
$id_tutor = $alumnos->id_tutor;
|
| 212 |
+
$id_grupo = $alumnos->id_grupo;
|
| 213 |
+
|
| 214 |
+
return view('admin.alumnos.show', [
|
| 215 |
+
'alumnos' => $alumnos
|
| 216 |
+
]);
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
public function edit(string $id){
|
| 220 |
+
$alumnos = Alumno::findOrFail($id);
|
| 221 |
+
$personas = Persona::all();
|
| 222 |
+
$tutores = Tutor::all();
|
| 223 |
+
$grupos = Grupo::all();
|
| 224 |
+
return view('admin.alumnos.edit', compact('alumnos', 'personas', 'grupos', 'tutores'));
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
public function update(Request $request, string $id){
|
| 228 |
+
$request->validate([
|
| 229 |
+
'persona_id' => 'required|string|max:50',
|
| 230 |
+
'numero_control' => ['required', 'string', 'max:50', Rule::unique('alumnos', 'numero_control')->ignore($id, 'id_alumno')],
|
| 231 |
+
'id_tutor' => 'required|string|max:50',
|
| 232 |
+
'id_grupo' => 'required|string|max:50',
|
| 233 |
+
'curp' => 'required|string|max:50',
|
| 234 |
+
'image' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048',
|
| 235 |
+
]);
|
| 236 |
+
|
| 237 |
+
$alumno = Alumno::findOrFail($id);
|
| 238 |
+
|
| 239 |
+
$grupo = Grupo::find($request->id_grupo);
|
| 240 |
+
|
| 241 |
+
$alumno->persona_id = $request->persona_id;
|
| 242 |
+
$alumno->numero_control = $request->numero_control;
|
| 243 |
+
$alumno->id_tutor = $request->id_tutor;
|
| 244 |
+
$alumno->id_grupo = $request->id_grupo;
|
| 245 |
+
$alumno->curp = $request->curp;
|
| 246 |
+
|
| 247 |
+
if ($request->hasFile('image')) {
|
| 248 |
+
|
| 249 |
+
if ($alumno->image_path && Storage::exists('public/' . $alumno->image_path)) {
|
| 250 |
+
Storage::delete('public/' . $alumno->image_path);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
$path = $request->file('image')->store('images', 'public');
|
| 254 |
+
$alumno->image_path = $path;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
$alumno->save();
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
if ($grupo) {
|
| 261 |
+
|
| 262 |
+
$gradoLimpio = str_replace('°', '', $grupo->grado);
|
| 263 |
+
|
| 264 |
+
return redirect()->route('alumnos.porGradoYGrupo', [
|
| 265 |
+
'grado' => $gradoLimpio,
|
| 266 |
+
'grupo' => $grupo->grupo
|
| 267 |
+
])->with('mensaje', 'Alumno actualizado con éxito.')
|
| 268 |
+
->with('icono', 'success');
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
return redirect()->route('alumnos.porGradoYGrupo')->with('mensaje', 'Alumno actualizado con éxito.')->with('icono', 'success');
|
| 272 |
+
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
public function destroy(string $id){
|
| 276 |
+
$alumno = Alumno::findOrFail($id);
|
| 277 |
+
$grupo = $alumno->grupo;
|
| 278 |
+
$alumno->delete();
|
| 279 |
+
if ($grupo) {
|
| 280 |
+
$gradoLimpio = str_replace('°', '', $grupo->grado);
|
| 281 |
+
return redirect()->route('alumnos.porGradoYGrupo', [
|
| 282 |
+
'grado' => $gradoLimpio,
|
| 283 |
+
'grupo' => $grupo->grupo
|
| 284 |
+
])->with('mensaje', 'Alumno eliminado con éxito.')
|
| 285 |
+
->with('icono', 'success');
|
| 286 |
+
}
|
| 287 |
+
return redirect()->route('alumnos.index')->with('mensaje', 'Alumno eliminado con éxito.')
|
| 288 |
+
->with('icono', 'success');
|
| 289 |
+
}
|
| 290 |
+
}
|
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 |
+
$usuarioRol = $usuario->id_rol;
|
| 24 |
+
|
| 25 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 53 |
+
|
| 54 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 76 |
+
|
| 77 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 78 |
+
|
| 79 |
+
if ($usuarioRol == 1) {
|
| 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 pdf1($id)
|
| 110 |
+
{
|
| 111 |
+
$usuario = Auth::user();
|
| 112 |
+
$persona = optional($usuario->persona);
|
| 113 |
+
$usuarioRol = $usuario->id_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($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_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($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 182 |
+
|
| 183 |
+
$avisos = Aviso::with('alumno')->findOrFail($id);
|
| 184 |
+
$alumno = $avisos->alumno;
|
| 185 |
+
|
| 186 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 210 |
+
|
| 211 |
+
$avisos = Aviso::findOrFail($id);
|
| 212 |
+
$alumno = $avisos->alumno;
|
| 213 |
+
|
| 214 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 54 |
+
|
| 55 |
+
$grado = $request->input('grado');
|
| 56 |
+
$grupo = $request->input('grupo');
|
| 57 |
+
|
| 58 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 114 |
+
|
| 115 |
+
$grado = $request->input('grado');
|
| 116 |
+
$grupo = $request->input('grupo');
|
| 117 |
+
|
| 118 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 174 |
+
|
| 175 |
+
$grado = $request->input('grado');
|
| 176 |
+
$grupo = $request->input('grupo');
|
| 177 |
+
|
| 178 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 234 |
+
|
| 235 |
+
$grado = $request->input('grado');
|
| 236 |
+
$grupo = $request->input('grupo');
|
| 237 |
+
|
| 238 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 294 |
+
|
| 295 |
+
$grado = $request->input('grado');
|
| 296 |
+
$grupo = $request->input('grupo');
|
| 297 |
+
|
| 298 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 357 |
+
|
| 358 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 384 |
+
|
| 385 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 408 |
+
|
| 409 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 432 |
+
|
| 433 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 456 |
+
|
| 457 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 480 |
+
|
| 481 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 778 |
+
|
| 779 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_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,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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->id_rol;
|
| 19 |
+
|
| 20 |
+
if (!in_array($rolNombre, [1, 2])) {
|
| 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 |
+
'grupo' => 'required|string|max:5',
|
| 45 |
+
'materia' => 'required|integer|max:10'
|
| 46 |
+
]);
|
| 47 |
+
|
| 48 |
+
$existeGrupo = Grupo::where('grupo', $request->grupo)
|
| 49 |
+
->where('grado', $request->grado)
|
| 50 |
+
->exists();
|
| 51 |
+
|
| 52 |
+
if ($existeGrupo) {
|
| 53 |
+
return redirect()->back()->with([
|
| 54 |
+
'mensaje' => 'El grado y grupo ya se encuentran registrados.',
|
| 55 |
+
'icono' => 'error'
|
| 56 |
+
]);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
$grupo = new Grupo();
|
| 60 |
+
$grupo->grupo = $request->grupo;
|
| 61 |
+
$grupo->grado = $request->grado;
|
| 62 |
+
$grupo->id_materia = $request->materia;
|
| 63 |
+
$grupo->save();
|
| 64 |
+
|
| 65 |
+
return redirect()->route('grupos.index')->with([
|
| 66 |
+
'mensaje' => 'Grupo creado con éxito.',
|
| 67 |
+
'icono' => 'success'
|
| 68 |
+
]);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Display the specified resource.
|
| 73 |
+
*/
|
| 74 |
+
public function show(string $id)
|
| 75 |
+
{
|
| 76 |
+
$grupos = Grupo::findOrFail($id);
|
| 77 |
+
return view('admin.grupos.show', ['grupos'=>$grupos]);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Show the form for editing the specified resource.
|
| 82 |
+
*/
|
| 83 |
+
public function edit(string $id)
|
| 84 |
+
{
|
| 85 |
+
$grupos = Grupo::with(['alumnos', 'gruposprefecto'])->findOrFail($id);
|
| 86 |
+
return view('admin.grupos.edit', compact('grupos'));
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Update the specified resource in storage.
|
| 91 |
+
*/
|
| 92 |
+
public function update(Request $request, string $id)
|
| 93 |
+
{
|
| 94 |
+
$request->validate([
|
| 95 |
+
'grado' => ['required', 'string', 'max:20', Rule::unique('grupos', 'grado')->ignore($id, 'id_grupo')],
|
| 96 |
+
'grupo' => ['required', 'string', 'max:20', Rule::unique('grupos', 'grupo')->ignore($id, 'id_grupo')],
|
| 97 |
+
]);
|
| 98 |
+
|
| 99 |
+
$grupos = Grupo::findOrFail($id);
|
| 100 |
+
$grupos->grado = $request->grado;
|
| 101 |
+
$grupos->grupo = $request->grupo;
|
| 102 |
+
$grupos->save();
|
| 103 |
+
|
| 104 |
+
return redirect()->route('grupos.index')->with('mensaje', 'Grupo actualizado con éxito.')
|
| 105 |
+
->with('icono', 'success');
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Remove the specified resource from storage.
|
| 110 |
+
*/
|
| 111 |
+
public function destroy(string $id)
|
| 112 |
+
{
|
| 113 |
+
$grupos = Grupo::findOrFail($id);
|
| 114 |
+
$grupos->delete();
|
| 115 |
+
|
| 116 |
+
return redirect()->route('grupos.index')->with('mensaje', 'Grupo eliminado con éxito.')
|
| 117 |
+
->with('icono', 'success');
|
| 118 |
+
}
|
| 119 |
+
}
|
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 |
+
$usuarioRol = $usuario->id_rol;
|
| 22 |
+
|
| 23 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 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/GruposAlumnosController.php
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace App\Http\Controllers;
|
| 4 |
+
|
| 5 |
+
use Illuminate\Http\Request;
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GruposAlumnosController extends Controller
|
| 10 |
+
{
|
| 11 |
+
/**
|
| 12 |
+
* Display a listing of the resource.
|
| 13 |
+
*/
|
| 14 |
+
public function index()
|
| 15 |
+
{
|
| 16 |
+
return 'index controller grupos';
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Show the form for creating a new resource.
|
| 21 |
+
*/
|
| 22 |
+
public function create()
|
| 23 |
+
{
|
| 24 |
+
//
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Store a newly created resource in storage.
|
| 29 |
+
*/
|
| 30 |
+
public function store(Request $request)
|
| 31 |
+
{
|
| 32 |
+
//
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Display the specified resource.
|
| 37 |
+
*/
|
| 38 |
+
public function show(string $id)
|
| 39 |
+
{
|
| 40 |
+
//
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Show the form for editing the specified resource.
|
| 45 |
+
*/
|
| 46 |
+
public function edit(string $id)
|
| 47 |
+
{
|
| 48 |
+
//
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Update the specified resource in storage.
|
| 53 |
+
*/
|
| 54 |
+
public function update(Request $request, string $id)
|
| 55 |
+
{
|
| 56 |
+
//
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Remove the specified resource from storage.
|
| 61 |
+
*/
|
| 62 |
+
public function destroy(string $id)
|
| 63 |
+
{
|
| 64 |
+
//
|
| 65 |
+
}
|
| 66 |
+
}
|
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 |
+
$usuarioRol = $usuario->id_rol;
|
| 24 |
+
|
| 25 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 53 |
+
|
| 54 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 76 |
+
|
| 77 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 78 |
+
|
| 79 |
+
if ($usuarioRol == 1) {
|
| 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 pdf1($id)
|
| 110 |
+
{
|
| 111 |
+
$usuario = Auth::user();
|
| 112 |
+
$persona = optional($usuario->persona);
|
| 113 |
+
$usuarioRol = $usuario->id_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($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_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($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 183 |
+
|
| 184 |
+
$justificantes = Justificante::with('alumno')->findOrFail($id);
|
| 185 |
+
$alumno = $justificantes->alumno;
|
| 186 |
+
|
| 187 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 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 |
+
$usuarioRol = $usuario->id_rol;
|
| 211 |
+
|
| 212 |
+
$justificantes = Justificante::findOrFail($id);
|
| 213 |
+
$alumno = $justificantes->alumno;
|
| 214 |
+
|
| 215 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 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 pdf1($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,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
public function index(){
|
| 14 |
+
$personas = Persona::all();
|
| 15 |
+
return view('admin.personas.index', ['personas'=>$personas]);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public function create(){
|
| 19 |
+
return view('admin.personas.create');
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
public function store(Request $request){
|
| 24 |
+
$request->validate([
|
| 25 |
+
'nombre' => 'required|string|max:255',
|
| 26 |
+
'apellido_paterno' => 'required|string|max:255',
|
| 27 |
+
'apellido_materno' => 'required|string|max:255',
|
| 28 |
+
'direccion' => 'required|string|max:255',
|
| 29 |
+
'fecha_nacimiento' => ['required', 'date', 'before:today'],
|
| 30 |
+
'telefono' => 'required|string|max:255|unique:personas,telefono',
|
| 31 |
+
'curp' => 'required|string|max:18|unique:personas,curp',
|
| 32 |
+
'id_rol' => 'nullable|exists:roles,id_rol'
|
| 33 |
+
]);
|
| 34 |
+
|
| 35 |
+
$persona = new Persona();
|
| 36 |
+
$persona->nombre = $request->nombre;
|
| 37 |
+
$persona->apellido_paterno = $request->apellido_paterno;
|
| 38 |
+
$persona->apellido_materno = $request->apellido_materno;
|
| 39 |
+
$persona->direccion = $request->direccion;
|
| 40 |
+
$persona->fecha_nacimiento = $request->fecha_nacimiento;
|
| 41 |
+
$persona->telefono = $request->telefono;
|
| 42 |
+
$persona->curp = $request->curp;
|
| 43 |
+
$persona->save();
|
| 44 |
+
|
| 45 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona creada con éxito.')
|
| 46 |
+
->with('icono', 'success');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function show($id){
|
| 50 |
+
$personas = Persona::findOrFail($id);
|
| 51 |
+
$roles = Rol::all();
|
| 52 |
+
return view('admin.personas.show', ['personas'=>$personas]);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
public function edit($id){
|
| 56 |
+
$persona = Persona::with(['usuario', 'alumno', 'tutor',])->findOrFail($id);
|
| 57 |
+
$roles = Rol::all();
|
| 58 |
+
return view('admin.personas.edit', compact('persona', 'roles'));
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
public function update(Request $request, string $id){
|
| 62 |
+
$request->validate([
|
| 63 |
+
'nombre' => 'required|string|max:50',
|
| 64 |
+
'apellido_paterno' => 'required|string|max:50',
|
| 65 |
+
'apellido_materno' => 'required|string|max:50',
|
| 66 |
+
'direccion' => 'required|string|max:50',
|
| 67 |
+
'fecha_nacimiento' => ['required', 'date', 'before:today'],
|
| 68 |
+
'telefono' => ['required', 'string', 'max:10', Rule::unique('personas', 'telefono')->ignore($id, 'id_persona')],
|
| 69 |
+
'id_rol' => 'required|integer',
|
| 70 |
+
'curp' => ['required', 'string', 'max:18', Rule::unique('personas', 'curp')->ignore($id, 'id_persona')],
|
| 71 |
+
]);
|
| 72 |
+
|
| 73 |
+
$personas = Persona::findOrFail($id);
|
| 74 |
+
$personas->nombre = $request->nombre;
|
| 75 |
+
$personas->apellido_paterno = $request->apellido_paterno;
|
| 76 |
+
$personas->apellido_materno = $request->apellido_materno;
|
| 77 |
+
$personas->direccion = $request->direccion;
|
| 78 |
+
$personas->fecha_nacimiento = $request->fecha_nacimiento;
|
| 79 |
+
$personas->telefono = $request->telefono;
|
| 80 |
+
$personas->curp = $request->curp;
|
| 81 |
+
$personas->save();
|
| 82 |
+
|
| 83 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona actualizada con éxito.')
|
| 84 |
+
->with('icono', 'success');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
public function destroy(string $id){
|
| 88 |
+
$personas = Persona::findOrFail($id);
|
| 89 |
+
$personas->delete();
|
| 90 |
+
|
| 91 |
+
return redirect()->route('personas.index')->with('mensaje', 'Persona eliminada con éxito.')
|
| 92 |
+
->with('icono', 'success');
|
| 93 |
+
}
|
| 94 |
+
}
|
app/app/Http/Controllers/ReporteController.php
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
* Display a listing of the resource.
|
| 17 |
+
*/
|
| 18 |
+
public function index()
|
| 19 |
+
{
|
| 20 |
+
$usuario = Auth::user();
|
| 21 |
+
$persona = $usuario->persona;
|
| 22 |
+
$usuarioRol = $usuario->id_rol;
|
| 23 |
+
|
| 24 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 25 |
+
$reportes = Reporte::with('alumno.persona', 'alumno.grupo')->get();
|
| 26 |
+
return view('admin.reportes.index', compact('reportes'));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 30 |
+
->pluck('id_grupo')
|
| 31 |
+
->toArray();
|
| 32 |
+
|
| 33 |
+
if (empty($gruposAsignados)) {
|
| 34 |
+
return redirect()->back()->with('error', 'No tienes grupos asignados.');
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$reportes = Reporte::whereHas('alumno', function ($query) use ($gruposAsignados) {
|
| 38 |
+
$query->whereIn('id_grupo', $gruposAsignados);
|
| 39 |
+
})->with('alumno.persona', 'alumno.grupo')->get();
|
| 40 |
+
|
| 41 |
+
return view('admin.reportes.index', compact('reportes'));
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Show the form for creating a new resource.
|
| 46 |
+
*/
|
| 47 |
+
public function create()
|
| 48 |
+
{
|
| 49 |
+
$usuario = auth()->user();
|
| 50 |
+
$persona = $usuario->persona;
|
| 51 |
+
$usuarioRol = $usuario->id_rol;
|
| 52 |
+
|
| 53 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 54 |
+
$alumnos = Alumno::with('persona')->get();
|
| 55 |
+
} else {
|
| 56 |
+
|
| 57 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 58 |
+
->pluck('id_grupo');
|
| 59 |
+
|
| 60 |
+
$alumnos = Alumno::whereIn('id_grupo', $gruposAsignados)->get();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
$personas = Persona::all();
|
| 64 |
+
return view('admin.reportes.create', compact('alumnos', 'personas'));
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Store a newly created resource in storage.
|
| 69 |
+
*/
|
| 70 |
+
public function store(Request $request)
|
| 71 |
+
{
|
| 72 |
+
$usuario = auth()->user();
|
| 73 |
+
$persona = $usuario->persona;
|
| 74 |
+
$usuarioRol = $usuario->id_rol;
|
| 75 |
+
|
| 76 |
+
$alumno = Alumno::find($request->id_alumno);
|
| 77 |
+
|
| 78 |
+
if ($usuarioRol == 1) {
|
| 79 |
+
|
| 80 |
+
} else {
|
| 81 |
+
|
| 82 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 83 |
+
->pluck('id_grupo');
|
| 84 |
+
|
| 85 |
+
if (!$alumno || !$gruposAsignados->contains($alumno->id_grupo)) {
|
| 86 |
+
return redirect()->back()->with('error', 'No tienes permiso para hacer este reporte a este alumno.');
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
//dd($request->all());
|
| 90 |
+
$request->validate([
|
| 91 |
+
'id_alumno' => 'required|string|max:50',
|
| 92 |
+
'persona_id' => 'required|string|max:50',
|
| 93 |
+
'contenido' => 'required|string|max:255',
|
| 94 |
+
'fecha' => 'required|date|max:50'
|
| 95 |
+
]);
|
| 96 |
+
|
| 97 |
+
$reportes = new Reporte();
|
| 98 |
+
$reportes->id_alumno = $request->id_alumno;
|
| 99 |
+
$reportes->persona_id = $request->persona_id;
|
| 100 |
+
$reportes->contenido = $request->contenido;
|
| 101 |
+
$reportes->fecha = $request->fecha;
|
| 102 |
+
$reportes->save();
|
| 103 |
+
|
| 104 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reporte creado con éxito.')
|
| 105 |
+
->with('icono', 'success');
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
public function pdf1($id)
|
| 109 |
+
{
|
| 110 |
+
$usuario = Auth::user();
|
| 111 |
+
$persona = optional($usuario->persona);
|
| 112 |
+
$usuarioRol = $usuario->id_rol;
|
| 113 |
+
|
| 114 |
+
$reportes = Reporte::with(['alumno.persona'])->findOrFail($id);
|
| 115 |
+
$alumno = $reportes->alumno;
|
| 116 |
+
|
| 117 |
+
if (!$alumno) {
|
| 118 |
+
return redirect()->back()->with('error', 'No se encontró el alumno asociado al reporte.');
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 122 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 123 |
+
->pluck('id_grupo')
|
| 124 |
+
->toArray();
|
| 125 |
+
|
| 126 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 127 |
+
abort(403, 'Acceso denegado: No puedes ver este PDF.');
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
$tutor = $alumno->tutor->persona ?? null;
|
| 132 |
+
$elaborador = $reportes->elaborador ?? null;
|
| 133 |
+
|
| 134 |
+
$periodo = Periodo::latest()->first();
|
| 135 |
+
|
| 136 |
+
$pdf = PDF::loadView('admin.reportes.pdf', compact('alumno', 'reportes', 'periodo', 'tutor', 'elaborador'));
|
| 137 |
+
|
| 138 |
+
return $pdf->stream();
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Display the specified resource.
|
| 143 |
+
*/
|
| 144 |
+
public function show(string $id)
|
| 145 |
+
{
|
| 146 |
+
$usuario = Auth::user();
|
| 147 |
+
$persona = $usuario->persona;
|
| 148 |
+
$usuarioRol = $usuario->id_rol;
|
| 149 |
+
|
| 150 |
+
$reportes = Reporte::with('alumno.persona', 'creador')->findOrFail($id);
|
| 151 |
+
$alumno = $reportes->alumno;
|
| 152 |
+
$personaAlumno = $alumno->persona;
|
| 153 |
+
$creador = $reportes->creador;
|
| 154 |
+
$contenido = $reportes->contenido;
|
| 155 |
+
$fecha = $reportes->fecha;
|
| 156 |
+
|
| 157 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 158 |
+
return view('admin.reportes.show', compact('alumno', 'personaAlumno', 'creador', 'contenido', 'fecha'));
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $usuario->persona_id)
|
| 162 |
+
->pluck('id_grupo')
|
| 163 |
+
->toArray();
|
| 164 |
+
|
| 165 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 166 |
+
abort(403, 'Acceso denegado. No puedes ver este reporte.');
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
return view('admin.reportes.show', compact('alumno', 'personaAlumno', 'creador', 'contenido', 'fecha'));
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Show the form for editing the specified resource.
|
| 174 |
+
*/
|
| 175 |
+
public function edit(string $id)
|
| 176 |
+
{
|
| 177 |
+
$usuario = Auth::user();
|
| 178 |
+
$persona = optional($usuario->persona);
|
| 179 |
+
$usuarioRol = $usuario->id_rol;
|
| 180 |
+
|
| 181 |
+
$reportes = Reporte::with('alumno')->findOrFail($id);
|
| 182 |
+
$alumno = $reportes->alumno;
|
| 183 |
+
|
| 184 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 185 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 186 |
+
->pluck('id_grupo')
|
| 187 |
+
->toArray();
|
| 188 |
+
|
| 189 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 190 |
+
abort(403, 'Acceso denegado: No puedes editar este reporte.');
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
$alumnos = Alumno::all();
|
| 195 |
+
$personas = Persona::all();
|
| 196 |
+
|
| 197 |
+
return view('admin.reportes.edit', compact('alumnos', 'personas', 'reportes'));
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Update the specified resource in storage.
|
| 202 |
+
*/
|
| 203 |
+
public function update(Request $request, string $id)
|
| 204 |
+
{
|
| 205 |
+
$usuario = Auth::user();
|
| 206 |
+
$persona = optional($usuario->persona);
|
| 207 |
+
$usuarioRol = $usuario->id_rol;
|
| 208 |
+
|
| 209 |
+
$reportes = Reporte::findOrFail($id);
|
| 210 |
+
$alumno = $reportes->alumno;
|
| 211 |
+
|
| 212 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 213 |
+
$gruposAsignados = GrupoPrefecto::where('persona_id', $persona->id_persona)
|
| 214 |
+
->pluck('id_grupo')
|
| 215 |
+
->toArray();
|
| 216 |
+
|
| 217 |
+
if (!in_array($alumno->id_grupo, $gruposAsignados)) {
|
| 218 |
+
abort(403, 'Acceso denegado: No puedes modificar este reporte.');
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
//dd($request->all());
|
| 222 |
+
$request->validate([
|
| 223 |
+
'id_alumno' => 'nullable|string|max:50',
|
| 224 |
+
'persona_id' => 'nullable|string|max:50',
|
| 225 |
+
'contenido' => 'required|string|max:255',
|
| 226 |
+
'fecha' => 'required|date|max:50'
|
| 227 |
+
]);
|
| 228 |
+
|
| 229 |
+
$reportes = Reporte::findOrFail($id);
|
| 230 |
+
$reportes->id_alumno = $request->id_alumno;
|
| 231 |
+
$reportes->persona_id = $request->persona_id;
|
| 232 |
+
$reportes->contenido = $request->contenido;
|
| 233 |
+
$reportes->fecha = $request->fecha;
|
| 234 |
+
$reportes->save();
|
| 235 |
+
|
| 236 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reportes actualizado con éxito.')
|
| 237 |
+
->with('icono', 'success');
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Remove the specified resource from storage.
|
| 242 |
+
*/
|
| 243 |
+
public function destroy(string $id)
|
| 244 |
+
{
|
| 245 |
+
$reportes = Reporte::findOrFail($id);
|
| 246 |
+
$reportes->delete();
|
| 247 |
+
return redirect()->route('reportes.index')->with('mensaje', 'Reporte eliminado con éxito.')
|
| 248 |
+
->with('icono', 'success');
|
| 249 |
+
}
|
| 250 |
+
}
|
app/app/Http/Controllers/RolController.php
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
public function index(){
|
| 15 |
+
$usuario = auth()->user();
|
| 16 |
+
$usuarioRol = $usuario->id_rol;
|
| 17 |
+
|
| 18 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 19 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
$roles = Rol::all();
|
| 23 |
+
return view('admin.roles.index', ['roles'=>$roles]);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
public function create(){
|
| 28 |
+
return view('admin.roles.create');
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
public function store(Request $request){
|
| 33 |
+
$request->validate([
|
| 34 |
+
'nombre_rol' => 'required|string|max:100|unique:roles,nombre_rol',
|
| 35 |
+
]);
|
| 36 |
+
|
| 37 |
+
$roles = new Rol();
|
| 38 |
+
$roles->nombre_rol = $request->nombre_rol;
|
| 39 |
+
$roles->save();
|
| 40 |
+
|
| 41 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se registro el rol de la manera correcta')
|
| 42 |
+
->with('icono', 'success');
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
public function show($id){
|
| 47 |
+
$roles = Rol::findOrFail($id);
|
| 48 |
+
return view('admin.roles.show', ['roles'=>$roles]);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
public function edit($id){
|
| 53 |
+
$roles = Rol::findOrFail($id);
|
| 54 |
+
return view('admin.roles.edit', ['roles'=>$roles]);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
public function update(Request $request, string $id){
|
| 59 |
+
$request->validate([
|
| 60 |
+
'nombre_rol' => ['required', 'string', 'max:15', Rule::unique('roles', 'nombre_rol')->ignore($id, 'id_rol')],
|
| 61 |
+
]);
|
| 62 |
+
|
| 63 |
+
$roles = Rol::find($id);
|
| 64 |
+
$roles->nombre_rol = $request->nombre_rol;
|
| 65 |
+
$roles->save();
|
| 66 |
+
|
| 67 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se actualizo el rol de la manera correcta')
|
| 68 |
+
->with('icono', 'success');
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
public function destroy($id){
|
| 72 |
+
Rol::destroy($id);
|
| 73 |
+
return redirect()->route('roles.index')->with('mensaje', 'Se elimino el rol de la manera correcta')
|
| 74 |
+
->with('icono', 'success');
|
| 75 |
+
}
|
| 76 |
+
}
|
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 |
+
$usuarioRol = $usuario->id_rol;
|
| 21 |
+
|
| 22 |
+
if (in_array($usuarioRol, [1, 2])) {
|
| 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,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
* Display a listing of the resource.
|
| 17 |
+
*/
|
| 18 |
+
public function index()
|
| 19 |
+
{
|
| 20 |
+
$usuario = auth()->user();
|
| 21 |
+
$usuarioRol = $usuario->id_rol;
|
| 22 |
+
// var_dump($usuario->id_rol);
|
| 23 |
+
if (!in_array($usuarioRol, [1, 2])) {
|
| 24 |
+
abort(403, 'Acceso denegado: No tienes permisos para acceder a esta sección.');
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
$usuarios = Usuario::with('persona', 'rol')->get();
|
| 28 |
+
return view('admin.usuarios.index', compact('usuarios'));
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Show the form for creating a new resource.
|
| 33 |
+
*/
|
| 34 |
+
public function create()
|
| 35 |
+
{
|
| 36 |
+
$personas = Persona::all();
|
| 37 |
+
$roles = Rol::all();
|
| 38 |
+
return view('admin.usuarios.create', compact('personas', 'roles'));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Store a newly created resource in storage.
|
| 43 |
+
*/
|
| 44 |
+
public function store(Request $request)
|
| 45 |
+
{
|
| 46 |
+
$request->validate([
|
| 47 |
+
'nombre_usuario' => 'required|string|max:50|unique:usuarios,nombre_usuario',
|
| 48 |
+
'email' => 'required|string|max:50|unique:usuarios,email',
|
| 49 |
+
'id_rol' => 'required|string|max:50',
|
| 50 |
+
'persona_id' => 'required|string|max:50',
|
| 51 |
+
'password' => 'required|confirmed'
|
| 52 |
+
|
| 53 |
+
]);
|
| 54 |
+
|
| 55 |
+
$usuarios = new Usuario();
|
| 56 |
+
$usuarios->nombre_usuario = $request->nombre_usuario;
|
| 57 |
+
$usuarios->email = $request->email;
|
| 58 |
+
$usuarios->id_rol = $request->id_rol;
|
| 59 |
+
$usuarios->persona_id = $request->persona_id;
|
| 60 |
+
$usuarios->password = Hash::make($request->password);
|
| 61 |
+
$usuarios->save();
|
| 62 |
+
|
| 63 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario creado con éxito.')
|
| 64 |
+
->with('icono', 'success');
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Display the specified resource.
|
| 69 |
+
*/
|
| 70 |
+
public function show($id)
|
| 71 |
+
{
|
| 72 |
+
$usuario = Usuario::with('persona', 'rol')->findOrFail($id);
|
| 73 |
+
$persona = $usuario->persona;
|
| 74 |
+
$rol = $usuario->rol;
|
| 75 |
+
|
| 76 |
+
return view('admin.usuarios.show', [
|
| 77 |
+
'usuario' => $usuario,
|
| 78 |
+
'persona' => $persona,
|
| 79 |
+
'rol' => $rol
|
| 80 |
+
]);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Show the form for editing the specified resource.
|
| 85 |
+
*/
|
| 86 |
+
public function edit(string $id)
|
| 87 |
+
{
|
| 88 |
+
$usuarios = Usuario::findOrFail($id);
|
| 89 |
+
$personas = Persona::all();
|
| 90 |
+
$roles = Rol::all();
|
| 91 |
+
return view('admin.usuarios.edit', compact('usuarios', 'personas', 'roles'));
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Update the specified resource in storage.
|
| 96 |
+
*/
|
| 97 |
+
public function update(Request $request, string $id)
|
| 98 |
+
{
|
| 99 |
+
$request->validate([
|
| 100 |
+
'nombre_usuario' => ['required', 'string', 'max:100', Rule::unique('usuarios', 'nombre_usuario')->ignore($id, 'id_usuario')],
|
| 101 |
+
'email' => ['required', 'string', 'max:100', Rule::unique('usuarios', 'email')->ignore($id, 'id_usuario')],
|
| 102 |
+
'id_rol' => 'required|integer',
|
| 103 |
+
'password' => 'nullable|confirmed',
|
| 104 |
+
]);
|
| 105 |
+
|
| 106 |
+
$usuarios = Usuario::findOrFail($id);
|
| 107 |
+
$usuarios->nombre_usuario = $request->nombre_usuario;
|
| 108 |
+
$usuarios->email = $request->email;
|
| 109 |
+
$usuarios->id_rol = $request->id_rol;
|
| 110 |
+
$usuarios->password = Hash::make($request['password']);
|
| 111 |
+
$usuarios->save();
|
| 112 |
+
|
| 113 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario 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 |
+
$usuario = Usuario::findOrFail($id);
|
| 123 |
+
$usuario->delete();
|
| 124 |
+
|
| 125 |
+
return redirect()->route('usuarios.index')->with('mensaje', 'Usuario eliminado con éxito.')
|
| 126 |
+
->with('icono', 'success');
|
| 127 |
+
}
|
| 128 |
+
}
|
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,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 persona()//: HasOne
|
| 29 |
+
{
|
| 30 |
+
return $this->belongsTo(Persona::class, 'persona_id');
|
| 31 |
+
//return $this->hasOne(Persona::Class);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function tutor()
|
| 35 |
+
{
|
| 36 |
+
return $this->belongsTo(Tutor::class, 'id_tutor');
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function grupo()
|
| 40 |
+
{
|
| 41 |
+
return $this->belongsTo(Grupo::class, 'id_grupo');
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
public function calificaciones()
|
| 45 |
+
{
|
| 46 |
+
return $this->hasMany(Calificacion::class, 'id_alumno');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function reportes()
|
| 50 |
+
{
|
| 51 |
+
return $this->hasMany(Reporte::class, 'id_alumno');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public function justificantes()
|
| 55 |
+
{
|
| 56 |
+
return $this->hasMany(Justificante::class, 'id_alumno');
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function avisos()
|
| 60 |
+
{
|
| 61 |
+
return $this->hasMany(Aviso::class, 'id_alumno');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function grupo_grado()
|
| 65 |
+
{
|
| 66 |
+
if ($this->grupo) {
|
| 67 |
+
return $this->grupo->grado . '°' . $this->grupo->grupo;
|
| 68 |
+
}
|
| 69 |
+
return 'Grado no asignado';
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
}
|