Initial Commit
This commit is contained in:
commit
c6c2f78d16
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
67
.env.example
Normal file
67
.env.example
Normal file
@ -0,0 +1,67 @@
|
||||
APP_NAME=Template
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_COPYRIGHT=Notsoweb
|
||||
APP_PAGINATION=50
|
||||
APP_MAINTENANCE_LIFETIME=48
|
||||
TELESCOPE_ENABLED=false
|
||||
|
||||
REPOSITORY_BRANCH=main
|
||||
REPOSITORY_WATCHER_PORT=3001
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=template
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=pusher
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=template
|
||||
PUSHER_APP_KEY=example
|
||||
PUSHER_APP_SECRET=my-secret
|
||||
PUSHER_HOST=localhost
|
||||
PUSHER_PORT=6001
|
||||
PUSHER_SCHEME=http
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
PUSHER_NOTIFICATIONS=false
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
VITE_PUSHER_NOTIFICATIONS="${PUSHER_NOTIFICATIONS}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
* text=auto
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/build.zip
|
||||
/public/hot
|
||||
/public/storage
|
||||
/public/vendor/telescope
|
||||
/packages
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
auth.json
|
||||
build.zip
|
||||
colors.json
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
soketi.json
|
||||
yarn-error.log
|
||||
74
README.md
Normal file
74
README.md
Normal file
@ -0,0 +1,74 @@
|
||||
|
||||
## Acerca de Template Laravel Vue
|
||||
Template es una plantilla que contiene un administrador con elementos simples como formularios, botones, tablas entre otros para acelerar el desarrollo. Permite tener preparada la gestión de usuarios, perfiles, entre otras cosas.
|
||||
|
||||
Este proyecto tiene como núcleo Laravel 10, Intertiajs y Vuejs 3.
|
||||
## Instalar proyecto
|
||||
#### Requerimientos
|
||||
Para instalar este proyecto se requiere tener instalado como mínimo las siguientes dependencias:
|
||||
- Composer 2.5.7
|
||||
- Nodejs 18.17.0
|
||||
- NPM 9.6.7
|
||||
- La base de datos es a discreción del usuario.
|
||||
#### Instalación
|
||||
El proyecto es capas de configurarse a si mismo si todas las dependencias están satisfechas. Para instalar el proyecto corra:
|
||||
``
|
||||
composer env:prod
|
||||
``
|
||||
o si lo prefiere:
|
||||
``
|
||||
composer env:dev
|
||||
``
|
||||
Se instalara el ambiente de producción o desarrollo respectivamente.
|
||||
|
||||
Una vez configurado el archivo .env con la base de datos, puede sembrar la base de datos:
|
||||
``
|
||||
composer db:prod
|
||||
``
|
||||
o si desea instalarla con el modo desarrollo:
|
||||
``
|
||||
composer db:dev
|
||||
``
|
||||
|
||||
#### Notificaciones en tiempo real
|
||||
Si se desea aprovechar el servicio de notificaciones en tiempo real integrado, se requiere instalar SOKETI y PM2.
|
||||
``
|
||||
npm install -g @soketi/soketi
|
||||
``
|
||||
``
|
||||
npm install -g pm2
|
||||
``
|
||||
También puede ejecutar el instalador integrado:
|
||||
``
|
||||
php artisan composer notification:install
|
||||
``
|
||||
En caso de error, procure usar privilegios de super usuario.
|
||||
|
||||
Para iniciar el servicio debe iniciarlo con el comando:
|
||||
``
|
||||
php artisan notification:start
|
||||
``
|
||||
O si desea detenerlo:
|
||||
``
|
||||
php artisan notification:stop
|
||||
``
|
||||
En caso de una desactivación permanente, puede eliminar la instancia:
|
||||
``
|
||||
php artisan notification:destroy
|
||||
``
|
||||
|
||||
Puede configurar libremente el servidor de notificaciones como usted desee con el archivo ``soketi.json``. Entre los parámetros editables están:
|
||||
- Puerto
|
||||
- ID de la instancia
|
||||
- KEY de la instancia
|
||||
- SECRETE de la instancia
|
||||
|
||||
El archivo de configuración se crea automáticamente al instalar el proyecto. Recuerde colocar los datos que edite de ``soketi.json`` en la configuración de PUSHER en el ``.env``.
|
||||
|
||||
El nombre de la instancia del servicio de notificaciones dentro de PM2 sera el mismo que se establezca en PUSHER_APP_KEY dentro del ``.env``. Es posible que sea conveniente modificar este dato si desea correr dos o más instancias de la aplicación dentro del mismo servidor para evitar que las notificaciones se compartan entre instancias. En caso contrario no es necesario modificar nada.
|
||||
|
||||
La aplicación puede funcionar bien con el establecimiento de un proxy inverso mediante NGINX si se requiere establecer un subdominio o dominio como puerta de enlace al servidor de notificaciones.
|
||||
|
||||
Por default las notificaciones están desactivadas. Se activan cambiando la variable de entorno ``PUSHER_NOTIFICATIONS`` de ``false`` a ``true``.
|
||||
## Autor
|
||||
Este proyecto fue desarrollado por Moisés de Jesús Cortés Castellanos. Si tiene alguna duda o recomendación, enviar a [ing.moisesdejesuscortesc@notsoweb.com](mailto:ing.moisesdejesuscortesc@notsoweb.com).
|
||||
40
app/Actions/Fortify/CreateNewUser.php
Normal file
40
app/Actions/Fortify/CreateNewUser.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and create a newly registered user.
|
||||
*
|
||||
* @param array $input
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
public function create(array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'paternal' => ['required', 'string', 'max:255'],
|
||||
'maternal' => ['nullable', 'string', 'max:255'],
|
||||
'phone' => ['nullable', 'numeric', 'digits:10', 'unique:users'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => $this->passwordRules(),
|
||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||
])->validate();
|
||||
|
||||
return User::create([
|
||||
'name' => $input['name'],
|
||||
'paternal' => $input['paternal'],
|
||||
'maternal' => $input['maternal'],
|
||||
'phone' => $input['phone'],
|
||||
'email' => $input['email'],
|
||||
'password' => Hash::make($input['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
16
app/Actions/Fortify/PasswordValidationRules.php
Normal file
16
app/Actions/Fortify/PasswordValidationRules.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace App\Actions\Fortify;
|
||||
|
||||
use Laravel\Fortify\Rules\Password;
|
||||
|
||||
trait PasswordValidationRules
|
||||
{
|
||||
/**
|
||||
* Get the validation rules used to validate passwords.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function passwordRules()
|
||||
{
|
||||
return ['required', 'string', 'min:8', 'confirmed'];
|
||||
}
|
||||
}
|
||||
28
app/Actions/Fortify/ResetUserPassword.php
Normal file
28
app/Actions/Fortify/ResetUserPassword.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
||||
|
||||
class ResetUserPassword implements ResetsUserPasswords
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and reset the user's forgotten password.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function reset($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
31
app/Actions/Fortify/UpdateUserPassword.php
Normal file
31
app/Actions/Fortify/UpdateUserPassword.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
|
||||
|
||||
class UpdateUserPassword implements UpdatesUserPasswords
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and update the user's password.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function update($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'current_password' => ['required', 'string', 'current_password:web'],
|
||||
'password' => $this->passwordRules(),
|
||||
], [
|
||||
'current_password.current_password' => __('passwords.no_match'),
|
||||
])->validateWithBag('updatePassword');
|
||||
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
66
app/Actions/Fortify/UpdateUserProfileInformation.php
Normal file
66
app/Actions/Fortify/UpdateUserProfileInformation.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
||||
|
||||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
||||
{
|
||||
/**
|
||||
* Validate and update the given user's profile information.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function update($user, array $input)
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'paternal' => ['required', 'string', 'max:255'],
|
||||
'maternal' => ['nullable', 'string', 'max:255'],
|
||||
'phone' => ['nullable', 'numeric', 'digits:10', Rule::unique('users')->ignore($user->id)],
|
||||
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
|
||||
'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'],
|
||||
])->validateWithBag('updateProfileInformation');
|
||||
|
||||
if (isset($input['photo'])) {
|
||||
$user->updateProfilePhoto($input['photo']);
|
||||
}
|
||||
|
||||
if ($input['email'] !== $user->email &&
|
||||
$user instanceof MustVerifyEmail) {
|
||||
$this->updateVerifiedUser($user, $input);
|
||||
} else {
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'paternal' => $input['paternal'],
|
||||
'maternal' => $input['maternal'],
|
||||
'phone' => $input['phone'],
|
||||
'email' => $input['email'],
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given verified user's profile information.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
protected function updateVerifiedUser($user, array $input)
|
||||
{
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'paternal' => $input['paternal'],
|
||||
'maternal' => $input['maternal'],
|
||||
'phone' => $input['phone'],
|
||||
'email' => $input['email'],
|
||||
'email_verified_at' => null,
|
||||
])->save();
|
||||
|
||||
$user->sendEmailVerificationNotification();
|
||||
}
|
||||
}
|
||||
19
app/Actions/Jetstream/DeleteUser.php
Normal file
19
app/Actions/Jetstream/DeleteUser.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php namespace App\Actions\Jetstream;
|
||||
|
||||
use Laravel\Jetstream\Contracts\DeletesUsers;
|
||||
|
||||
class DeleteUser implements DeletesUsers
|
||||
{
|
||||
/**
|
||||
* Delete the given user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @return void
|
||||
*/
|
||||
public function delete($user)
|
||||
{
|
||||
$user->deleteProfilePhoto();
|
||||
$user->tokens->each->delete();
|
||||
$user->delete();
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/DownSecure.php
Normal file
57
app/Console/Commands/DownSecure.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
/**
|
||||
* Inicia el modo mantenimiento con una clave secreta
|
||||
*
|
||||
* De forma automática pondrá al sistema en modo mantenimiento con una URL secreta para
|
||||
* poder acceder al sitio. El tiempo se puede configurar desde las variables de entorno.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class DownSecure extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'down:secure';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Modo mantenimiento con un hash seguro';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$secret = Uuid::uuid4();
|
||||
|
||||
Artisan::call('down', [
|
||||
'--secret' => $secret
|
||||
]);
|
||||
|
||||
echo url($secret);
|
||||
echo "\n";
|
||||
|
||||
Log::channel('notsoweb')->info("Maintenance Mode Secure. Key: {$secret}");
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
51
app/Console/Commands/NotificationGlobal.php
Normal file
51
app/Console/Commands/NotificationGlobal.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Events\GlobalNotification;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Lanza notificaciones a usuarios en linea
|
||||
*
|
||||
* La notificación es única y no persistente.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NotificationGlobal extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'notification:global {message}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Enviar notificación a todos los usuarios';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$message = $this->argument('message');
|
||||
|
||||
broadcast(new GlobalNotification(
|
||||
$message,
|
||||
"info",
|
||||
15
|
||||
));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/NotificationStart.php
Normal file
42
app/Console/Commands/NotificationStart.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Iniciar servicio de notificaciones
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NotificationStart extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'notification:start';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Iniciar servicio de notificaciones en tiempo real';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
echo shell_exec('pm2 start soketi --name notification-server -- start --config=soketi.json');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/NotificationStop.php
Normal file
42
app/Console/Commands/NotificationStop.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Detener servicio de notificaciones
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NotificationStop extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'notification:stop';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Detener servicio de notificaciones en tiempo real';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
echo shell_exec('pm2 delete notification-server');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
46
app/Console/Commands/NotsowebInstall.php
Normal file
46
app/Console/Commands/NotsowebInstall.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Instala dependencias especiales
|
||||
*
|
||||
* Instala los componentes necesarios para que funcionen las notificaciones en tiempo real y la
|
||||
* actualización en tiempo real.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NotsowebInstall extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'notsoweb:install';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Instala los servicios necesarios para las notificaciones y actualizaciones en tiempo real';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
echo shell_exec('npm install -g @soketi/soketi');
|
||||
echo shell_exec('npm install -g pm2');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/UpdaterStart.php
Normal file
42
app/Console/Commands/UpdaterStart.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Iniciar servicio de actualización automática
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UpdaterStart extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'updater:start';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Iniciar servicio de actualización automática';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
shell_exec("pm2 start --name updater \"node updater.js\"");
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/UpdaterStop.php
Normal file
42
app/Console/Commands/UpdaterStop.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Detener servicio de actualización automática
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UpdaterStop extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'updater:stop';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Detener servicio de actualización automática';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
shell_exec("pm2 delete updater");
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
78
app/Console/Commands/UserNotification.php
Normal file
78
app/Console/Commands/UserNotification.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Models\User;
|
||||
use App\Notifications\UserHeaderNotification;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Lanza notificaciones a usuario especifico
|
||||
*
|
||||
* La notificación queda guardada en las notificaciones del usuario.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UserNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'notification:user
|
||||
{--email=developer@notsoweb.com : Correo del usuario}
|
||||
{--message=Prueba : Mensaje a enviar}
|
||||
{--type=info : Tipo de notificación}
|
||||
{--timeout=15 : Tiempo de notificación en segundos}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Notificar algo a un usuario especifico mediante consola';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$email = $this->option('email');
|
||||
$message = $this->option('message');
|
||||
$type = $this->option('type');
|
||||
$timeout = $this->option('timeout');
|
||||
|
||||
if($email) {
|
||||
$user = User::where('email', $email)->first();
|
||||
|
||||
if ($user) {
|
||||
$user->notify(new UserHeaderNotification(
|
||||
message: $message,
|
||||
icon: $type,
|
||||
timeout: $timeout
|
||||
));
|
||||
|
||||
Log::channel('notify')->info("Mensaje privado enviado por consola a {$user->email}");
|
||||
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$log = "El usuario {$user->email} no existe, mensaje por consola no enviado.";
|
||||
|
||||
echo $log;
|
||||
Log::channel('notify')->error($log);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "Se necesita escribir un correo";
|
||||
}
|
||||
|
||||
return Command::INVALID;
|
||||
}
|
||||
}
|
||||
65
app/Console/Commands/Uuid.php
Normal file
65
app/Console/Commands/Uuid.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Ramsey\Uuid\Uuid as RamseyUuid;
|
||||
|
||||
/**
|
||||
* Genera un UUID en consola
|
||||
*
|
||||
* Diseñado para generar un ID único que necesitan ser generados en caliente.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Uuid extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:uuid {type=uuid4}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Genera un uuid en consola';
|
||||
|
||||
/**
|
||||
* Tipos permitidos
|
||||
*/
|
||||
protected $types = [
|
||||
'uuid1',
|
||||
'uuid2',
|
||||
'uuid3',
|
||||
'uuid4',
|
||||
'uuid5',
|
||||
'uuid6',
|
||||
'uuid7',
|
||||
'uuid8',
|
||||
];
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$type = $this->argument('type');
|
||||
|
||||
if(in_array($type, $this->types)) {
|
||||
echo "Type: $type \n";
|
||||
echo RamseyUuid::$type();
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
return Command::INVALID;
|
||||
}
|
||||
}
|
||||
30
app/Console/Kernel.php
Normal file
30
app/Console/Kernel.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
49
app/Events/GlobalNotification.php
Normal file
49
app/Events/GlobalNotification.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Notificación global
|
||||
*
|
||||
* Lanza notificaciones a todos los usuarios con sesión iniciada.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class GlobalNotification implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable,
|
||||
InteractsWithSockets,
|
||||
SerializesModels;
|
||||
|
||||
/**
|
||||
* Crear nueva instancia del evento
|
||||
*
|
||||
* @param string $message El mensaje a transmitir
|
||||
* @param string $type El tipo de mensaje
|
||||
* @param string $timeout Tiempo en segundos
|
||||
*/
|
||||
public function __construct(
|
||||
public $message,
|
||||
public $type = 'success',
|
||||
public $timeout = 15
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Transmitir notificación por canal privado
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel("notifications");
|
||||
}
|
||||
}
|
||||
48
app/Exceptions/Handler.php
Normal file
48
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
211
app/Http/Controllers/Admin/UserController.php
Normal file
211
app/Http/Controllers/Admin/UserController.php
Normal file
@ -0,0 +1,211 @@
|
||||
<?php namespace App\Http\Controllers\Admin;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Requests\StoreUser;
|
||||
use App\Http\Requests\UpdateUser;
|
||||
use App\Http\Traits\UseFetch;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
use Notsoweb\Core\Http\Traits\Controllers\WithPermission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
/**
|
||||
* Controla los usuarios del sistema
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UserController extends VueController
|
||||
{
|
||||
use UseFetch,
|
||||
WithPermission;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->vueRoot('admin.user');
|
||||
$this->withDefaultPermissions('users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar usuarios
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$q = request()->get('q');
|
||||
|
||||
return $this->vuew('index', [
|
||||
'users' => User::whereNotIn('id', [1,2])
|
||||
->where(fn($query) => $query
|
||||
->where('name', 'LIKE', "%{$q}%")
|
||||
->orWhere('email', 'LIKE', "%{$q}%"))
|
||||
->select([
|
||||
'id',
|
||||
'name',
|
||||
'paternal',
|
||||
'maternal',
|
||||
'email',
|
||||
'phone'
|
||||
])
|
||||
->paginate(config('app.pagination')),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mostrar formulario crear usuario
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->vuew('create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Almacenar usuario
|
||||
*/
|
||||
public function store(StoreUser $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
// Cifro la contraseña recibida
|
||||
$data['password'] = bcrypt($data['password']);
|
||||
|
||||
User::create($data);
|
||||
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vista configurar usuario
|
||||
*
|
||||
* @param User $user Modelo del usuario
|
||||
*/
|
||||
public function settings(User $user)
|
||||
{
|
||||
return $this->vuew('settings', [
|
||||
'user' => $user,
|
||||
'userRoles' => $user->roles,
|
||||
'roles'=> Role::orderBy('name', 'ASC')
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar usuario
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param User $user Modelo del usuario
|
||||
*/
|
||||
public function update(UpdateUser $request, $user) : void
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
$model = User::find($user);
|
||||
$model->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar contraseña usuario
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function updatePassword(Request $request) : void
|
||||
{
|
||||
$data = $this->validate($request, [
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
'user_id' => ['required'],
|
||||
]);
|
||||
|
||||
$user = User::find($data['user_id']);
|
||||
$user->update([
|
||||
'password' => Hash::make($data['password'])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sincronizar roles usuario
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function syncRoles(Request $request) : void
|
||||
{
|
||||
$data = $this->validate($request, [
|
||||
'roles' => ['nullable'],
|
||||
'user_id' => ['required']
|
||||
]);
|
||||
|
||||
$roles = [];
|
||||
|
||||
foreach ($data['roles'] as $role) {
|
||||
$roles[] = $role['id'];
|
||||
}
|
||||
|
||||
$user = User::find($data['user_id']);
|
||||
$user->syncRoles($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener notificaciones
|
||||
*
|
||||
* Trae las ultimas 7 notificaciones.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function getNotifications() : JsonResponse
|
||||
{
|
||||
try {
|
||||
$notifications = auth()
|
||||
->user()
|
||||
->notifications()
|
||||
->limit(7)
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
return $this->successFetch([
|
||||
'notifications' => $notifications
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
$this->reportError($th, __METHOD__);
|
||||
return $this->errorFetch(__('The user does not have notifications'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar usuario
|
||||
*
|
||||
* @param integer $user ID del usuario
|
||||
*/
|
||||
public function destroy($user) : void
|
||||
{
|
||||
try {
|
||||
$user = User::find($user);
|
||||
$user->delete();
|
||||
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('users')
|
||||
->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log de errores
|
||||
*
|
||||
* @param object $th Contiene todos los detalles del error
|
||||
* @param string $method Función del controlador sobre la que ocurrió el error
|
||||
*/
|
||||
private function reportError($th, $method) : void
|
||||
{
|
||||
Log::channel('users')->error("Method: $method");
|
||||
Log::channel('users')->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Traits\ReportAction;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ReportAction;
|
||||
}
|
||||
67
app/Http/Controllers/Dashboard/HistoryLogController.php
Normal file
67
app/Http/Controllers/Dashboard/HistoryLogController.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php namespace App\Http\Controllers\Dashboard;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Models\HistoryLog;
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
|
||||
/**
|
||||
* Controla el historial de acciones de los usuarios
|
||||
*
|
||||
* Permite ver los registros de las acciones de los usuarios.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class HistoryLogController extends VueController
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->vueRoot('dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar historial de acciones
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$historyEvent = request()->get('historyEvent');
|
||||
$dateStart = request()->get('dateStart');
|
||||
$dateEnd = request()->get('dateEnd');
|
||||
|
||||
if($dateEnd) {
|
||||
$dateEnd = date('Y-m-d', strtotime("{$dateEnd} + 1 day"));
|
||||
}
|
||||
|
||||
$searcher = HistoryLog::join('users', 'users.id', '=', 'history_logs.user_id')
|
||||
->where(function($query) use ($historyEvent) {
|
||||
$query->where('history_logs.action', 'LIKE', "%{$historyEvent}%");
|
||||
$query->orWhere('history_logs.message', 'LIKE', "%{$historyEvent}%");
|
||||
});
|
||||
|
||||
if($dateStart && $dateEnd) {
|
||||
$searcher = $searcher->whereBetween('history_logs.created_at', [$dateStart, $dateEnd]);
|
||||
} elseif($dateStart && !$dateEnd) {
|
||||
$searcher = $searcher->where('history_logs.created_at', '>=', $dateStart);
|
||||
} elseif (!$dateStart && $dateEnd) {
|
||||
$searcher = $searcher->where('history_logs.created_at', '<=', $dateEnd);
|
||||
}
|
||||
|
||||
return $this->vuew('history-log' , [
|
||||
'histories' => $searcher ->select([
|
||||
'history_logs.*',
|
||||
'users.name',
|
||||
'users.paternal',
|
||||
])
|
||||
->orderBy('created_at', 'Desc')
|
||||
->paginate(config('app.pagination'))
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Dashboard/IndexController.php
Normal file
32
app/Http/Controllers/Dashboard/IndexController.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php namespace App\Http\Controllers\Dashboard;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
|
||||
/**
|
||||
* Controlador de la página de inicio del dashboard del usuario
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class IndexController extends VueController
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->vueRoot('dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Página de inicio
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->vuew('index');
|
||||
}
|
||||
}
|
||||
102
app/Http/Controllers/Dashboard/NotificationController.php
Normal file
102
app/Http/Controllers/Dashboard/NotificationController.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php namespace App\Http\Controllers\Dashboard;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Notifications\DatabaseNotification as Notification;
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
|
||||
/**
|
||||
* Controlador muy simple de las notificaciones del usuario
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NotificationController extends VueController
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->vueRoot('dashboard.notifications');
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar notificaciones usuario
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$dateStart = request()->get('dateStart');
|
||||
$dateEnd = request()->get('dateEnd');
|
||||
|
||||
if($dateEnd) {
|
||||
$dateEnd = date('Y-m-d', strtotime("{$dateEnd} + 1 day"));
|
||||
}
|
||||
|
||||
$searcher = auth()
|
||||
->user()
|
||||
->notifications()
|
||||
->latest();
|
||||
|
||||
if($dateStart && $dateEnd) {
|
||||
$searcher = $searcher->whereBetween('notifications.created_at', [$dateStart, $dateEnd]);
|
||||
} elseif($dateStart && !$dateEnd) {
|
||||
$searcher = $searcher->where('notifications.created_at', '>=', $dateStart);
|
||||
} elseif (!$dateStart && $dateEnd) {
|
||||
$searcher = $searcher->where('notifications.created_at', '<=', $dateEnd);
|
||||
}
|
||||
|
||||
return $this->vuew('index', [
|
||||
'notifications' => $searcher->paginate(config('app.pagination'))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marcar notificación como leída
|
||||
*
|
||||
* Al entrar a ver los detalles de la notificación esta se marca como leída automáticamente.
|
||||
* Aprovechando el método post para no mostrar el ID.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
$notification = Notification::find($data['id']);
|
||||
$notification->markAsRead();
|
||||
|
||||
return $this->vuew('show', [
|
||||
'notification' => $notification
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marcar notificación como leída
|
||||
*
|
||||
* Marca directamente una notificación como leída sin siquiera entrar a detalles.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Notification $notification Modelo de la notificación
|
||||
*/
|
||||
public function update(Request $request, Notification $notification)
|
||||
{
|
||||
$notification->markAsRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar notificación
|
||||
*
|
||||
* @param Notification $notification Modelo de la notificación
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Notification $notification)
|
||||
{
|
||||
$notification->delete();
|
||||
}
|
||||
}
|
||||
113
app/Http/Controllers/Developer/RoleController.php
Normal file
113
app/Http/Controllers/Developer/RoleController.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php namespace App\Http\Controllers\Developer;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Http\Request;
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
use Notsoweb\Core\Http\Traits\Controllers\WithPermission;
|
||||
|
||||
/**
|
||||
* Administra los roles del sistema
|
||||
*
|
||||
* CRUD de los roles. Algunos roles están implícitos en el código para dar permisos. Por lo que
|
||||
* es un controlador sensible.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class RoleController extends VueController
|
||||
{
|
||||
use WithPermission;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->withDefaultPermissions('roles');
|
||||
$this->vueRoot('developer.roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar roles
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$q = request()->get('q');
|
||||
|
||||
return $this->vuew('index', [
|
||||
'roles' => Role::orderBy('name', 'ASC')
|
||||
->where('name', 'LIKE', "%{$q}%")
|
||||
->select([
|
||||
'id',
|
||||
'name',
|
||||
'description'
|
||||
])
|
||||
->paginate(config('app.pagination'))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vista nuevo rol
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->vuew('create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Almacenar role
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => ['required', 'string'],
|
||||
'description' => ['required', 'string']
|
||||
]);
|
||||
|
||||
Role::create($data);
|
||||
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar role
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Role $role Modelo del Role
|
||||
*/
|
||||
public function update(Request $request, $role) : void
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => ['required', 'string'],
|
||||
'description' => ['required', 'string']
|
||||
]);
|
||||
|
||||
$model = Role::find($role);
|
||||
$model->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar rol
|
||||
*
|
||||
* Se debe de tener mucho cuidado en la eliminación de los roles ya que algunos de ellos
|
||||
* están ligados a nivel código en el sistema, lo que podría limitar a los usuarios o
|
||||
* bloquear el sistema.
|
||||
*
|
||||
* @param Role $role Modelo del Role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Role $role) : void
|
||||
{
|
||||
$role->delete();
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Example/IndexController.php
Normal file
32
app/Http/Controllers/Example/IndexController.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php namespace App\Http\Controllers\Example;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Notsoweb\Core\Http\Controllers\VueController;
|
||||
|
||||
/**
|
||||
* Controlador de la página de inicio de los ejemplos
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class IndexController extends VueController
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->vueRoot('example');
|
||||
}
|
||||
|
||||
/**
|
||||
* Página de inicio
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->vuew('index');
|
||||
}
|
||||
}
|
||||
55
app/Http/Controllers/ResourceController.php
Normal file
55
app/Http/Controllers/ResourceController.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* @copyright Copyright (c) 2001-2022 Golsystems (https://www.golsystems.mx) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Traits\UseFetch;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Permite traer recursos estáticos que son solo para consulta
|
||||
*
|
||||
* Retorna la información necesaria para los select, listas o recursos determinados.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class ResourceController extends Controller
|
||||
{
|
||||
use UseFetch;
|
||||
|
||||
/**
|
||||
* Retornar todos los roles del usuario
|
||||
*
|
||||
* @param int $user ID del usuario a buscar roles
|
||||
*/
|
||||
public function rolesByUser($user) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$model = User::find($user);
|
||||
|
||||
return $this->successFetch([
|
||||
'roles' => $model->roles
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
$this->reportError($th, __METHOD__);
|
||||
|
||||
return $this->errorFetch(__('The user does not exist'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear log de errores de este controlador
|
||||
*
|
||||
* @param object $th Contiene todos los detalles del error
|
||||
* @param string $method Función del controlador sobre la que ocurrió el error
|
||||
*/
|
||||
private function reportError($th, $method) : void
|
||||
{
|
||||
Log::channel('resources')->error("Method: $method");
|
||||
Log::channel('resources')->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
70
app/Http/Kernel.php
Normal file
70
app/Http/Kernel.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\HandleInertiaRequests::class,
|
||||
\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
26
app/Http/MaintenanceModeBypassCookie.php
Normal file
26
app/Http/MaintenanceModeBypassCookie.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\MaintenanceModeBypassCookie as HttpMaintenanceModeBypassCookie;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
class MaintenanceModeBypassCookie extends HttpMaintenanceModeBypassCookie
|
||||
{
|
||||
/**
|
||||
* Create a new maintenance mode bypass cookie.
|
||||
*
|
||||
* @param string $key
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
public static function create(string $key)
|
||||
{
|
||||
$expiresAt = Carbon::now()->addHours(config('app.maintenance.lifetime'));//Time expiration for your cookie
|
||||
|
||||
return new Cookie('laravel_maintenance', base64_encode(json_encode([
|
||||
'expires_at' => $expiresAt->getTimestamp(),
|
||||
'mac' => hash_hmac('sha256', $expiresAt->getTimestamp(), $key),
|
||||
])), $expiresAt);
|
||||
}
|
||||
}
|
||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
44
app/Http/Middleware/HandleInertiaRequests.php
Normal file
44
app/Http/Middleware/HandleInertiaRequests.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
|
||||
class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
/**
|
||||
* The root template that's loaded on the first page visit.
|
||||
*
|
||||
* @see https://inertiajs.com/server-side-setup#root-template
|
||||
* @var string
|
||||
*/
|
||||
protected $rootView = 'app';
|
||||
|
||||
/**
|
||||
* Determines the current asset version.
|
||||
*
|
||||
* @see https://inertiajs.com/asset-versioning
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
public function version(Request $request): ?string
|
||||
{
|
||||
return config('app.version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the props that are shared by default.
|
||||
*
|
||||
* @see https://inertiajs.com/shared-data
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function share(Request $request): array
|
||||
{
|
||||
return array_merge(parent::share($request), [
|
||||
'copyright' => config('app.copyright'),
|
||||
'lang'=> config('app.locale'),
|
||||
'shareUserPermissions' => auth()?->user()?->getAllPermissions(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
29
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\MaintenanceModeBypassCookie;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Configura el secreto de forma personalizada con una duración de tiempo
|
||||
* personalizada en las variables de entorno.
|
||||
*/
|
||||
protected function bypassResponse(string $secret)
|
||||
{
|
||||
return redirect('/')->withCookie(
|
||||
MaintenanceModeBypassCookie::create($secret)
|
||||
);
|
||||
}
|
||||
}
|
||||
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
15
app/Http/Middleware/VerifyCsrfToken.php
Normal file
15
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'/hook/*'
|
||||
];
|
||||
}
|
||||
43
app/Http/Requests/StoreUser.php
Normal file
43
app/Http/Requests/StoreUser.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Valida el almacenamiento de un usuario
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class StoreUser extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determinar si el usuario esta autorizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reglas de validación
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string'],
|
||||
'paternal' => ['required', 'string'],
|
||||
'maternal' => ['nullable', 'string'],
|
||||
'email' => ['required', 'email', 'unique:users'],
|
||||
'phone' => ['nullable', 'numeric', 'unique:users'],
|
||||
'password' => ['required', 'min:8'],
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Requests/UpdateUser.php
Normal file
43
app/Http/Requests/UpdateUser.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Valida la actualización de los usuarios
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UpdateUser extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determinar si el usuario esta autorizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reglas de validación
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string'],
|
||||
'paternal' => ['required', 'string'],
|
||||
'maternal' => ['nullable', 'string'],
|
||||
'email' => ['required', 'email', Rule::unique('users')->ignore($this->id)],
|
||||
'phone' => ['nullable', 'numeric', Rule::unique('users')->ignore($this->id)],
|
||||
];
|
||||
}
|
||||
}
|
||||
58
app/Http/Traits/ModelExtend.php
Normal file
58
app/Http/Traits/ModelExtend.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php namespace App\Http\Traits;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extención de los modelos para funciones adicionales
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
* @version 1.0.0
|
||||
*/
|
||||
trait ModelExtend
|
||||
{
|
||||
/**
|
||||
* Retorna en un array los atributos rellenados que son rellenables.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fillableToArray() : array
|
||||
{
|
||||
if(count($this->fillable) > 0) {
|
||||
$data = [];
|
||||
|
||||
foreach($this->fillable as $fillable) {
|
||||
if(!in_array($fillable, $this->hidden)){
|
||||
$data[$fillable] = $this->$fillable;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna los cambios de una actualización separandolos como antes y despues
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContrastChanges() : array
|
||||
{
|
||||
$new = $old = [];
|
||||
$changes = $this->getChanges();
|
||||
|
||||
foreach (array_keys($changes) as $key) {
|
||||
if(!in_array($key, ['updated_at'])) {
|
||||
$new[$key] = $changes[$key];
|
||||
$old[$key] = $this->getOriginal($key);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'new' => $new,
|
||||
'old' => $old,
|
||||
];
|
||||
}
|
||||
}
|
||||
107
app/Http/Traits/ReportAction.php
Normal file
107
app/Http/Traits/ReportAction.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php namespace App\Http\Traits;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Conjunto de funciones para automatizar el manejo de rutas de vistas de vue en los
|
||||
* controladores asemejando la forma de llamar a las vistas a la de blade.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
* @version 1.0.0
|
||||
*/
|
||||
trait ReportAction
|
||||
{
|
||||
/**
|
||||
* Reporta una cantidad de algo
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $action Accion completa
|
||||
* @param array $json Array de datos
|
||||
* @param int $qty Cantidad de datos
|
||||
* @param string $context Información adicional
|
||||
*/
|
||||
public function reportQty(string $action, array $json = [], int $qty = 1, string $attribute = null) : void
|
||||
{
|
||||
Log::channel('report')->info($attribute ,[
|
||||
'qty' => $qty,
|
||||
'action'=> $action,
|
||||
'data' => $json
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reporta la duplicación de un registro
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $module Modulo sobre el que se desencadena la acción
|
||||
* @param array $json Array de datos
|
||||
* @param string $context Información adicional
|
||||
*/
|
||||
public function reportDuplicated(string $module, array $json, string $context = null) : void
|
||||
{
|
||||
$this->reportQty(
|
||||
action:"{$module}.duplicated",
|
||||
json: $json,
|
||||
attribute: $context
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reporta la creación de un registro
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $module Modulo sobre el que se desencadena la acción
|
||||
* @param array $json Array de datos
|
||||
* @param string $context Información adicional
|
||||
*/
|
||||
public function reportCreate(string $module, array $json, string $context = null) : void
|
||||
{
|
||||
$this->reportQty(
|
||||
action:"{$module}.created",
|
||||
json: $json,
|
||||
attribute: $context
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reporta la actualización de un registro
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $module Modulo sobre el que se desencadena la acción
|
||||
* @param array $json Array de datos
|
||||
* @param string $context Información adicional
|
||||
*/
|
||||
public function reportUpdate(string $module, array $json, string $context = null) : void
|
||||
{
|
||||
$this->reportQty(
|
||||
action:"{$module}.updated",
|
||||
json: $json,
|
||||
attribute: $context
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reporta la eliminación de un registro
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $module Modulo sobre el que se desencadena la acción
|
||||
* @param array $json Array de datos
|
||||
* @param string $context Información adicional
|
||||
*/
|
||||
public function reportDestroy(string $module, array $json, string $context = null) : void
|
||||
{
|
||||
$this->reportQty(
|
||||
action:"{$module}.destroyed",
|
||||
json: $json,
|
||||
attribute: $context
|
||||
);
|
||||
}
|
||||
}
|
||||
54
app/Http/Traits/UseFetch.php
Normal file
54
app/Http/Traits/UseFetch.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php namespace App\Http\Traits;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* Permite comunicarse con el componente useFetch javascript.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
* @version 1.0.0
|
||||
*/
|
||||
trait UseFetch
|
||||
{
|
||||
/**
|
||||
* Retorna un mensaje de error para fetch
|
||||
*
|
||||
* Para aquellas peticiones realizadas por medio de la función fetch en javascript que
|
||||
* requieran retornar un error.
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @return \Illuminate\Http\JSONResponse
|
||||
*/
|
||||
public function errorFetch($message = null) : JsonResponse
|
||||
{
|
||||
if (!$message) {
|
||||
$message = __("Resource not found");
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 404,
|
||||
'message' => $message
|
||||
], 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna un mensaje de error para fetch
|
||||
*
|
||||
* Para aquellas peticiones realizadas por medio de la función fetch en javascript que
|
||||
* requieran retornar un error.
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @return \Illuminate\Http\JSONResponse
|
||||
*/
|
||||
public function successFetch(array $data = []) : JsonResponse
|
||||
{
|
||||
return response()->json(array_merge([
|
||||
'status' => 200,
|
||||
], $data));
|
||||
}
|
||||
}
|
||||
47
app/Http/Webhooks/UpdateAppHook.php
Normal file
47
app/Http/Webhooks/UpdateAppHook.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php namespace App\Http\Webhooks;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Recibe los eventos de actualización de la aplicación
|
||||
*
|
||||
* PRUEBA 5
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.1
|
||||
*/
|
||||
class UpdateAppHook extends Controller
|
||||
{
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$branch = config('app.repository.branch');
|
||||
$data = $request->all();
|
||||
|
||||
Log::channel('hook:update-app')->info('update:', $data);
|
||||
Log::channel('app:update')->info("Init updating {$branch} ...");
|
||||
|
||||
if($data['ref'] == "refs/heads/{$branch}") {
|
||||
if($data['before'] != $data['after']) {
|
||||
Artisan::call('app:update');
|
||||
|
||||
foreach ($data['commits'] as $commit) {
|
||||
Log::channel('app:update')->info($commit['message']);
|
||||
}
|
||||
Log::channel('app:update')->info('¡Updated!');
|
||||
} else {
|
||||
Log::channel('app:update')->info('No was updated');
|
||||
}
|
||||
} else {
|
||||
Log::channel('app:update')->info('Not is updatable');
|
||||
}
|
||||
|
||||
Log::channel('app:update')->info('Exit updating');
|
||||
}
|
||||
}
|
||||
46
app/Listeners/BrodcastUserLoginNotification.php
Normal file
46
app/Listeners/BrodcastUserLoginNotification.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Listeners;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Events\GlobalNotification;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
|
||||
/**
|
||||
* Escucha el inicio de sesión de los usuarios
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class BrodcastUserLoginNotification
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Disparador
|
||||
*
|
||||
* Transmite mediante el evento cambio de sesión un mensaje de inicio de sesión
|
||||
*
|
||||
* @param object $event
|
||||
*/
|
||||
public function handle(Login $event) : void
|
||||
{
|
||||
if(config('app.notifications')) {
|
||||
broadcast(new GlobalNotification(
|
||||
__('notifications.user.login', [
|
||||
'user' => $event->user->name
|
||||
]),
|
||||
'info'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Listeners/BrodcastUserLogoutNotification.php
Normal file
46
app/Listeners/BrodcastUserLogoutNotification.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Listeners;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Events\GlobalNotification;
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
|
||||
/**
|
||||
* Escucha el cierre de Session de un usuario
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class BrodcastUserLogoutNotification
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Disparador
|
||||
*
|
||||
* Transmite mediante el evento cambio de sesión un mensaje de cierre de sesión
|
||||
*
|
||||
* @param object $event
|
||||
*/
|
||||
public function handle(Logout $event) : void
|
||||
{
|
||||
if(config('app.notifications')) {
|
||||
broadcast(new GlobalNotification(
|
||||
__('notifications.user.logout', [
|
||||
'user' => $event->user->name
|
||||
]),
|
||||
'info'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Models/HistoryLog.php
Normal file
45
app/Models/HistoryLog.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php namespace App\Models;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Permite guardar el log de acciones de los usuarios
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class HistoryLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Atributos llenables masivamente
|
||||
*/
|
||||
protected $fillable = [
|
||||
'action',
|
||||
'qty',
|
||||
'message',
|
||||
'data',
|
||||
'user_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* Los atributos que deben transformarse.
|
||||
*/
|
||||
protected $casts = [
|
||||
'data' => 'json'
|
||||
];
|
||||
|
||||
/**
|
||||
* Un log pertenece a un usuario
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
34
app/Models/Role.php
Normal file
34
app/Models/Role.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Models;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Traits\ModelExtend;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Spatie\Permission\Models\Role as ModelsRole;
|
||||
|
||||
/**
|
||||
* Roles del sistema
|
||||
*
|
||||
* Los roles y permisos son controlados por Spatie\Permission. Este modelo solo es una
|
||||
* interfaz para poder visualizar los roles del sistema, o crear nuevos para el desarrollo
|
||||
* de vistas.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Role extends ModelsRole
|
||||
{
|
||||
use HasFactory,
|
||||
ModelExtend;
|
||||
|
||||
/**
|
||||
* Atributos llenables masivamente
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'guard_name',
|
||||
'description'
|
||||
];
|
||||
}
|
||||
110
app/Models/User.php
Normal file
110
app/Models/User.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php namespace App\Models;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Traits\ModelExtend;
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Laravel\Jetstream\HasProfilePhoto;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
/**
|
||||
* Usuarios del sistema
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens;
|
||||
use HasFactory;
|
||||
use HasProfilePhoto;
|
||||
use Notifiable;
|
||||
use TwoFactorAuthenticatable;
|
||||
use HasRoles;
|
||||
use ModelExtend;
|
||||
|
||||
/**
|
||||
* Atributos llenables masivamente
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'paternal',
|
||||
'maternal',
|
||||
'phone',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* Los atributos que deben ocultarse para la serialización.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_secret',
|
||||
];
|
||||
|
||||
/**
|
||||
* Los atributos que deben transformarse.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Los atributos calculados que se añadirán a la matriz del modelo.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [
|
||||
'full_name',
|
||||
'full_last_name',
|
||||
'profile_photo_url',
|
||||
];
|
||||
|
||||
/**
|
||||
* Un usuario a realizado muchas acciones
|
||||
*/
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(HistoryLog::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna nombre completo
|
||||
*/
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return "{$this->name} {$this->paternal} {$this->maternal}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retornar apellido completo
|
||||
*/
|
||||
public function getFullLastNameAttribute()
|
||||
{
|
||||
return "{$this->paternal} {$this->maternal}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retornar nombre con primer apellido
|
||||
*/
|
||||
public function getShortNameAttribute()
|
||||
{
|
||||
return "{$this->name} {$this->paternal}";
|
||||
}
|
||||
}
|
||||
75
app/Notifications/UserHeaderNotification.php
Normal file
75
app/Notifications/UserHeaderNotification.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php namespace App\Notifications;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
/**
|
||||
* Notificación para usuario especifico
|
||||
*
|
||||
* Notificación persistente para usuario especifico.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class UserHeaderNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Parámetros para detonar la notificación
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public string $message,
|
||||
public string $icon = 'notifications_active',
|
||||
public string $type = 'info',
|
||||
public int $timeout = 15
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Canales de envió de la notificación
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*/
|
||||
public function via($notifiable) : array
|
||||
{
|
||||
return [
|
||||
'broadcast',
|
||||
'database'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene la representación del array de la notificación.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable) : array
|
||||
{
|
||||
return [
|
||||
'message' => $this->message,
|
||||
'icon' => $this->icon,
|
||||
'type' => $this->type,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Manda un mensaje por medio de un broadcast privado
|
||||
*/
|
||||
public function toBroadcast($notifiable)
|
||||
{
|
||||
return new BroadcastMessage([
|
||||
'message' => $this->message,
|
||||
'icon' => $this->type,
|
||||
'timeout' => $this->timeout
|
||||
]);
|
||||
}
|
||||
}
|
||||
84
app/Observers/RoleObserver.php
Normal file
84
app/Observers/RoleObserver.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php namespace App\Observers;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Http\Traits\ReportAction;
|
||||
use App\Models\Role;
|
||||
|
||||
/**
|
||||
* Observador del modelo Role
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class RoleObserver
|
||||
{
|
||||
use ReportAction;
|
||||
|
||||
/**
|
||||
* Objeto del evento
|
||||
*/
|
||||
protected $event = 'roles';
|
||||
|
||||
/**
|
||||
* Handle the Role "created" event.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
*/
|
||||
public function created(Role $role) : void
|
||||
{
|
||||
$this->reportCreate($this->event, $role->fillableToArray(), __("{$this->event}.created", [
|
||||
'role' => $role->name
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Role "updated" event.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
*/
|
||||
public function updated(Role $role) : void
|
||||
{
|
||||
$this->reportUpdate($this->event, $role->getContrastChanges(), __("{$this->event}.updated", [
|
||||
'role' => $role->name
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Role "deleted" event.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
*/
|
||||
public function deleted(Role $role) : void
|
||||
{
|
||||
$this->reportDestroy($this->event, $role->fillableToArray(), __("{$this->event}.deleted", [
|
||||
'role' => $role->name
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Role "restored" event.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
*/
|
||||
public function restored(Role $role) : void
|
||||
{
|
||||
$this->reportUpdate($this->event, $role->fillableToArray(), __("{$this->event}.restored", [
|
||||
'role' => $role->name
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Role "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
*/
|
||||
public function forceDeleted(Role $role) : void
|
||||
{
|
||||
$this->reportDestroy($this->event, $role->fillableToArray(), __("{$this->event}.forceDeleted", [
|
||||
'role' => $role->name
|
||||
]));
|
||||
}
|
||||
}
|
||||
82
app/Observers/UserObserver.php
Normal file
82
app/Observers/UserObserver.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php namespace App\Observers;
|
||||
|
||||
use App\Http\Traits\ReportAction;
|
||||
use App\Models\User;
|
||||
|
||||
class UserObserver
|
||||
{
|
||||
use ReportAction;
|
||||
|
||||
/**
|
||||
* Objeto del evento
|
||||
*/
|
||||
protected $event = 'users';
|
||||
|
||||
/**
|
||||
* Handle the User "created" event.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*/
|
||||
public function created(User $user) : void
|
||||
{
|
||||
$this->reportCreate($this->event, $user->fillableToArray(), __("{$this->event}.created", [
|
||||
'user' => $user->fullName
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the User "updated" event.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*/
|
||||
public function updated(User $user) : int
|
||||
{
|
||||
$changes = $user->getChanges();
|
||||
|
||||
if(in_array('remember_token', array_keys($changes)) && count($changes) == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->reportUpdate($this->event, $user->getContrastChanges(), __("{$this->event}.updated", [
|
||||
'user' => $user->fullName
|
||||
]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the User "deleted" event.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*/
|
||||
public function deleted(User $user) : void
|
||||
{
|
||||
$this->reportDestroy($this->event, $user->fillableToArray(), __("{$this->event}.deleted", [
|
||||
'user' => $user->fullName
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the User "restored" event.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*/
|
||||
public function restored(User $user) : void
|
||||
{
|
||||
$this->reportUpdate($this->event, $user->fillableToArray(), __("{$this->event}.restored", [
|
||||
'user' => $user->fullName
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the User "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*/
|
||||
public function forceDeleted(User $user) : void
|
||||
{
|
||||
$this->reportDestroy($this->event, $user->fillableToArray(), __("{$this->event}.forceDeleted", [
|
||||
'user' => $user->fullName
|
||||
]));
|
||||
}
|
||||
}
|
||||
28
app/Providers/AppServiceProvider.php
Normal file
28
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
28
app/Providers/AuthServiceProvider.php
Normal file
28
app/Providers/AuthServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
61
app/Providers/EventServiceProvider.php
Normal file
61
app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\BrodcastUserLoginNotification;
|
||||
use App\Listeners\BrodcastUserLogoutNotification;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use App\Observers\RoleObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
Login::class => [
|
||||
BrodcastUserLoginNotification::class,
|
||||
],
|
||||
Logout::class => [
|
||||
BrodcastUserLogoutNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
protected $observers = [
|
||||
User::class => [UserObserver::class],
|
||||
Role::class => [RoleObserver::class],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
49
app/Providers/FortifyServiceProvider.php
Normal file
49
app/Providers/FortifyServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Actions\Fortify\CreateNewUser;
|
||||
use App\Actions\Fortify\ResetUserPassword;
|
||||
use App\Actions\Fortify\UpdateUserPassword;
|
||||
use App\Actions\Fortify\UpdateUserProfileInformation;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class FortifyServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Fortify::createUsersUsing(CreateNewUser::class);
|
||||
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
|
||||
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
|
||||
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
|
||||
|
||||
RateLimiter::for('login', function (Request $request) {
|
||||
$email = (string) $request->email;
|
||||
|
||||
return Limit::perMinute(5)->by($email.$request->ip());
|
||||
});
|
||||
|
||||
RateLimiter::for('two-factor', function (Request $request) {
|
||||
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
||||
});
|
||||
}
|
||||
}
|
||||
49
app/Providers/JetstreamServiceProvider.php
Normal file
49
app/Providers/JetstreamServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Actions\Jetstream\DeleteUser;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
class JetstreamServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configurePermissions();
|
||||
|
||||
Jetstream::deleteUsersUsing(DeleteUser::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the permissions that are available within the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configurePermissions()
|
||||
{
|
||||
Jetstream::defaultApiTokenPermissions(['read']);
|
||||
|
||||
Jetstream::permissions([
|
||||
'create',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
]);
|
||||
}
|
||||
}
|
||||
56
app/Providers/RouteServiceProvider.php
Normal file
56
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/dashboard/welcome';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->prefix('hook')
|
||||
->group(base_path('routes/hook.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
46
app/Services/Logs/LogHandler.php
Normal file
46
app/Services/Logs/LogHandler.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Services\Logs;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use App\Models\HistoryLog;
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
use Monolog\LogRecord;
|
||||
use Monolog\Level;
|
||||
|
||||
/**
|
||||
* Dispara el LOG
|
||||
*
|
||||
* Almacena las acciones de los usuarios en la base de datos
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class LogHandler extends AbstractProcessingHandler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($level = Level::Debug)
|
||||
{
|
||||
parent::__construct($level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escribe el log recibido
|
||||
*
|
||||
* @param array $record Array con la información a registrar
|
||||
*/
|
||||
protected function write(LogRecord $record) :void
|
||||
{
|
||||
// Simple store implementation
|
||||
$log = new HistoryLog();
|
||||
$log->fill($record->context);
|
||||
$log->fill([
|
||||
"message" => $record->message,
|
||||
"user_id" => auth()->user()->id
|
||||
]);
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
33
app/Services/Logs/LogMonolog.php
Normal file
33
app/Services/Logs/LogMonolog.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php namespace App\Services\Logs;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* Dispara el LOG
|
||||
*
|
||||
* Controla el flujo del registro del LOG.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class LogMonolog
|
||||
{
|
||||
/**
|
||||
* Create a custom Monolog instance.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Monolog\Logger
|
||||
*/
|
||||
public function __invoke(array $config)
|
||||
{
|
||||
$logger = new Logger('custom');
|
||||
$logger->pushProcessor(new LogProcessor());
|
||||
$logger->pushHandler(new LogHandler());
|
||||
|
||||
return $logger;
|
||||
}
|
||||
}
|
||||
23
app/Services/Logs/LogProcessor.php
Normal file
23
app/Services/Logs/LogProcessor.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Services\Logs;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Monolog\LogRecord;
|
||||
|
||||
/**
|
||||
* Modifica o agrega datos
|
||||
*
|
||||
* Agrega o modifica los datos del context del log.
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class LogProcessor
|
||||
{
|
||||
public function __invoke(LogRecord $record)
|
||||
{
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
117
app/Services/Notify.php
Normal file
117
app/Services/Notify.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php namespace App\Services;
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
||||
*/
|
||||
|
||||
use Inertia\Inertia;
|
||||
|
||||
/**
|
||||
* Permite enviar notificaciones mediante inertia
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Notify
|
||||
{
|
||||
/**
|
||||
* Notificación exitosa
|
||||
*/
|
||||
const SUCCESS = 'success';
|
||||
|
||||
/**
|
||||
* Notificación de error
|
||||
*/
|
||||
const ERROR = 'error';
|
||||
|
||||
/**
|
||||
* Notificación informativa
|
||||
*/
|
||||
const INFO = 'info';
|
||||
|
||||
/**
|
||||
* Notificación de advertencia
|
||||
*/
|
||||
const WARNING = 'warning';
|
||||
|
||||
/**
|
||||
* Inertia Flash
|
||||
*
|
||||
* Crea una notificación procesable por INERTIA para la siguiente petición
|
||||
* realizada en el FRONTEND
|
||||
*
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @param string $message Mensaje
|
||||
* @param string $type Tipo
|
||||
* @param string $key Llave de guardado
|
||||
*/
|
||||
public static function send($message, $type = 'success', $key = 'flash') : void
|
||||
{
|
||||
$old = Inertia::getShared($key, null);
|
||||
|
||||
$data = [
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
];
|
||||
|
||||
if($old) {
|
||||
Inertia::share($key, array_merge($old, [$data]));
|
||||
} else {
|
||||
Inertia::share($key, [$data]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica algo exitoso
|
||||
*
|
||||
* @param string $message Mensaje
|
||||
*/
|
||||
public static function success($message) : void
|
||||
{
|
||||
self::send(
|
||||
message: $message,
|
||||
type: self::SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica un error
|
||||
*
|
||||
* @param string $message Mensaje
|
||||
* @return void
|
||||
*/
|
||||
public static function error($message) : void
|
||||
{
|
||||
self::send(
|
||||
message: $message,
|
||||
type: self::ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica algo informativo
|
||||
*
|
||||
* @param string $message Mensaje
|
||||
*/
|
||||
public static function info($message) : void
|
||||
{
|
||||
self::send(
|
||||
message: $message,
|
||||
type: self::INFO
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica una advertencia
|
||||
*
|
||||
* @param string $message Mensaje
|
||||
*/
|
||||
public static function warning($message) : void
|
||||
{
|
||||
self::send(
|
||||
message: $message,
|
||||
type: self::WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
53
artisan
Normal file
53
artisan
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Artisan Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When we run the console application, the current CLI command will be
|
||||
| executed in this console and the response sent back to a terminal
|
||||
| or another output device for the developers. Here goes nothing!
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
|
||||
$status = $kernel->handle(
|
||||
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||
new Symfony\Component\Console\Output\ConsoleOutput
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running, we will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
||||
55
bootstrap/app.php
Normal file
55
bootstrap/app.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
2
bootstrap/cache/.gitignore
vendored
Executable file
2
bootstrap/cache/.gitignore
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
26
colors.json.example
Normal file
26
colors.json.example
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"page":"#E5E7EB",
|
||||
"page-on":"#4B5563",
|
||||
"page-dark":"#000",
|
||||
"page-dark-on":"#fff",
|
||||
"main":"#fff",
|
||||
"main-on":"#000",
|
||||
"main-dark":"#1E1F1C",
|
||||
"main-dark-on":"#fff",
|
||||
"primary":"#111827",
|
||||
"primary-on":"#fff",
|
||||
"primary-dark":"#000",
|
||||
"primary-dark-on":"#fff",
|
||||
"secondary":"#374151",
|
||||
"secondary-dark":"#989A9C",
|
||||
"white":"#FFFFFF",
|
||||
"white-dark":"#FFFFFF",
|
||||
"success":"#22C55E",
|
||||
"success-dark":"#22C55E",
|
||||
"warning":"#EAB308",
|
||||
"warning-dark":"#EAB308",
|
||||
"danger":"#EF4444",
|
||||
"danger-dark":"#EF4444",
|
||||
"info":"#3B82F6",
|
||||
"info-dark":"#3B82F6"
|
||||
}
|
||||
111
composer.json
Normal file
111
composer.json
Normal file
@ -0,0 +1,111 @@
|
||||
{
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1.0",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"inertiajs/inertia-laravel": "^0.6.3",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/jetstream": "^2.12",
|
||||
"laravel/sanctum": "^3.2",
|
||||
"laravel/tinker": "^2.7",
|
||||
"notsoweb/author": "^0.0",
|
||||
"notsoweb/core": "^0.1",
|
||||
"pusher/pusher-php-server": "^7.2",
|
||||
"spatie/laravel-permission": "^5.5",
|
||||
"tightenco/ziggy": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/telescope": "^4.10",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.0.1",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php -r \"file_exists('soketi.json') || copy('soketi.json.example', 'soketi.json');\"",
|
||||
"@php -r \"file_exists('colors.json') || copy('colors.json.example', 'colors.json');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
],
|
||||
"services:start" : [
|
||||
"@php artisan notification:start",
|
||||
"@php artisan updater:start"
|
||||
],
|
||||
"services:stop" : [
|
||||
"@php artisan notification:stop",
|
||||
"@php artisan updater:stop"
|
||||
],
|
||||
"env:dev": [
|
||||
"composer install",
|
||||
"composer run post-root-package-install",
|
||||
"composer run post-create-project-cmd",
|
||||
"npm install",
|
||||
"npm run build",
|
||||
"@php artisan storage:link"
|
||||
],
|
||||
"env:prod": [
|
||||
"composer install --no-dev",
|
||||
"composer run post-root-package-install",
|
||||
"composer run post-create-project-cmd",
|
||||
"npm install",
|
||||
"npm run build",
|
||||
"@php artisan storage:link",
|
||||
"composer run services:start"
|
||||
],
|
||||
"env:prod-lite": [
|
||||
"composer install --no-dev",
|
||||
"composer run post-root-package-install",
|
||||
"composer run post-create-project-cmd"
|
||||
],
|
||||
"db:dev": [
|
||||
"@php artisan migrate:fresh --seeder=DevSeeder"
|
||||
],
|
||||
"db:prod": [
|
||||
"@php artisan migrate:fresh --seed"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
9211
composer.lock
generated
Normal file
9211
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
257
config/app.php
Normal file
257
config/app.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Version
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the version of your application. This value is used when the
|
||||
| frontend to display the version of your application.
|
||||
|
|
||||
*/
|
||||
'version' => '1.2.4',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Copyright
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the copyright of your application. This value is used when the
|
||||
| frontend to display the copyright of your application.
|
||||
|
|
||||
*/
|
||||
'copyright' => env('APP_COPYRIGHT', 'Notsoweb'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application. This value is used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| any other location as required by the application or its packages.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Notifications
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Notification in real time.
|
||||
|
|
||||
*/
|
||||
'notifications' => (bool) env('PUSHER_NOTIFICATIONS', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'America/Mexico_City',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'es',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'es',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Faker Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This locale will be used by the Faker PHP library when generating fake
|
||||
| data for your database seeds. For example, this will be used to get
|
||||
| localized telephone numbers, street address information and more.
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'es_MX',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => 'file',
|
||||
// 'store' => 'redis',
|
||||
'lifetime' => env('APP_MAINTENANCE_LIFETIME', 48), // in hours
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Other configuration
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'pagination' => env('APP_PAGINATION', 50),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
Illuminate\Auth\AuthServiceProvider::class,
|
||||
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
Illuminate\Cache\CacheServiceProvider::class,
|
||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||
Illuminate\Cookie\CookieServiceProvider::class,
|
||||
Illuminate\Database\DatabaseServiceProvider::class,
|
||||
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
||||
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||
Illuminate\Hashing\HashServiceProvider::class,
|
||||
Illuminate\Mail\MailServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Redis\RedisServiceProvider::class,
|
||||
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||
Illuminate\Session\SessionServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
Notsoweb\Author\Providers\AuthorServiceProvider::class,
|
||||
Notsoweb\Core\Providers\CoreServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\FortifyServiceProvider::class,
|
||||
App\Providers\JetstreamServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'ExampleClass' => App\Example\ExampleClass::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
111
config/auth.php
Normal file
111
config/auth.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default authentication "guard" and password
|
||||
| reset options for your application. You may change these defaults
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| here which uses session storage and the Eloquent user provider.
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| sources which represent each model / table. These sources may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may specify multiple password reset configurations if you have more
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expire time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| times out and the user is prompted to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
||||
70
config/broadcasting.php
Normal file
70
config/broadcasting.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Broadcaster
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default broadcaster that will be used by the
|
||||
| framework when an event needs to be broadcast. You may set this to
|
||||
| any of the connections defined in the "connections" array below.
|
||||
|
|
||||
| Supported: "pusher", "ably", "redis", "log", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('BROADCAST_DRIVER', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the broadcast connections that will be used
|
||||
| to broadcast events to other systems or over websockets. Samples of
|
||||
| each available type of connection are provided inside this array.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
110
config/cache.php
Normal file
110
config/cache.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache connection that gets used while
|
||||
| using this caching library. This connection is used when another is
|
||||
| not explicitly specified when executing a given caching function.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'cache',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
||||
34
config/cors.php
Normal file
34
config/cors.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
||||
151
config/database.php
Normal file
151
config/database.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for all database work. Of course
|
||||
| you may use many connections at once using the Database library.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'mysql'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here are each of the database connections setup for your application.
|
||||
| Of course, examples of configuring each database platform that is
|
||||
| supported by Laravel is shown below to make development simple.
|
||||
|
|
||||
|
|
||||
| All database work in Laravel is done through the PHP PDO facilities
|
||||
| so make sure you have the driver for your particular database of
|
||||
| choice installed on your machine before you begin development.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run in the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => 'migrations',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
76
config/filesystems.php
Normal file
76
config/filesystems.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application. Just store away!
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||
| may even configure multiple disks of the same driver. Defaults have
|
||||
| been set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
147
config/fortify.php
Normal file
147
config/fortify.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Laravel\Fortify\Features;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which authentication guard Fortify will use while
|
||||
| authenticating users. This value should correspond with one of your
|
||||
| guards that is already present in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => 'web',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Password Broker
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which password broker Fortify can use when a user
|
||||
| is resetting their password. This configured value should match one
|
||||
| of your password brokers setup in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => 'users',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Username / Email
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value defines which model attribute should be considered as your
|
||||
| application's "username" field. Typically, this might be the email
|
||||
| address of the users but you are free to change this value here.
|
||||
|
|
||||
| Out of the box, Fortify expects forgot password and reset password
|
||||
| requests to have a field named 'email'. If the application uses
|
||||
| another name for the field you may define it below as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'username' => 'email',
|
||||
|
||||
'email' => 'email',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Home Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the path where users will get redirected during
|
||||
| authentication or password reset when the operations are successful
|
||||
| and the user is authenticated. You are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'home' => RouteServiceProvider::HOME,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Prefix / Subdomain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which prefix Fortify will assign to all the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| subdomain under which all of the Fortify routes will be available.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => '',
|
||||
|
||||
'domain' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which middleware Fortify will assign to the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| these middleware but typically this provided default is preferred.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Rate Limiting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default, Fortify will throttle logins to five requests per minute for
|
||||
| every email and IP address combination. However, if you would like to
|
||||
| specify a custom rate limiter to call then you may specify it here.
|
||||
|
|
||||
*/
|
||||
|
||||
'limiters' => [
|
||||
'login' => 'login',
|
||||
'two-factor' => 'two-factor',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register View Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify if the routes returning views should be disabled as
|
||||
| you may not need them when building your own application. This may be
|
||||
| especially true if you're writing a custom single-page application.
|
||||
|
|
||||
*/
|
||||
|
||||
'views' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Features
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some of the Fortify features are optional. You may disable the features
|
||||
| by removing them from this array. You're free to only remove some of
|
||||
| these features or you can even remove all of these if you need to.
|
||||
|
|
||||
*/
|
||||
|
||||
'features' => [
|
||||
Features::registration(),
|
||||
Features::resetPasswords(),
|
||||
Features::emailVerification(),
|
||||
Features::updateProfileInformation(),
|
||||
Features::updatePasswords(),
|
||||
Features::twoFactorAuthentication([
|
||||
'confirm' => true,
|
||||
'confirmPassword' => true,
|
||||
// 'window' => 0,
|
||||
]),
|
||||
],
|
||||
|
||||
];
|
||||
52
config/hashing.php
Normal file
52
config/hashing.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Hash Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default hash driver that will be used to hash
|
||||
| passwords for your application. By default, the bcrypt algorithm is
|
||||
| used; however, you remain free to modify this option if you wish.
|
||||
|
|
||||
| Supported: "bcrypt", "argon", "argon2id"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'bcrypt',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bcrypt Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Bcrypt algorithm. This will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'bcrypt' => [
|
||||
'rounds' => env('BCRYPT_ROUNDS', 10),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Argon Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Argon algorithm. These will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'argon' => [
|
||||
'memory' => 65536,
|
||||
'threads' => 1,
|
||||
'time' => 4,
|
||||
],
|
||||
|
||||
];
|
||||
81
config/jetstream.php
Normal file
81
config/jetstream.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Jetstream\Features;
|
||||
use Laravel\Jetstream\Http\Middleware\AuthenticateSession;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Jetstream Stack
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This configuration value informs Jetstream which "stack" you will be
|
||||
| using for your application. In general, this value is set for you
|
||||
| during installation and will not need to be changed after that.
|
||||
|
|
||||
*/
|
||||
|
||||
'stack' => 'inertia',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Jetstream Route Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which middleware Jetstream will assign to the routes
|
||||
| that it registers with the application. When necessary, you may modify
|
||||
| these middleware; however, this default value is usually sufficient.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
'auth_session' => AuthenticateSession::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Jetstream Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the authentication guard Jetstream will use while
|
||||
| authenticating users. This value should correspond with one of your
|
||||
| guards that is already present in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => 'sanctum',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Features
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some of Jetstream's features are optional. You may disable the features
|
||||
| by removing them from this array. You're free to only remove some of
|
||||
| these features or you can even remove all of these if you need to.
|
||||
|
|
||||
*/
|
||||
|
||||
'features' => [
|
||||
Features::termsAndPrivacyPolicy(),
|
||||
Features::profilePhotos(),
|
||||
// Features::api(),
|
||||
// Features::teams(['invitations' => true]),
|
||||
Features::accountDeletion(),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Profile Photo Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This configuration value determines the default disk that will be used
|
||||
| when storing profile photos for your application's users. Typically
|
||||
| this will be the "public" disk but you may adjust this if needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'profile_photo_disk' => 'public',
|
||||
|
||||
];
|
||||
162
config/logging.php
Normal file
162
config/logging.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that gets used when writing
|
||||
| messages to the logs. The name specified in this option should match
|
||||
| one of the channels defined in the "channels" configuration array.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog",
|
||||
| "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['single'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => 14,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
'report' => [
|
||||
'driver' => 'custom',
|
||||
'via' => \App\Services\Logs\LogMonolog::class
|
||||
],
|
||||
|
||||
// Logs para los recursos obtenidos
|
||||
'resources' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/resources.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
// Logs de las acciones sobre los usuarios
|
||||
'users' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/users.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
// Logs para reportar notificaciones
|
||||
'notify' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/notify.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
// Webhooks
|
||||
'hook:update-app' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/webhooks/update-app.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
// Logs de las apps
|
||||
'app:update' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/app/update.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send any email
|
||||
| messages sent by your application. Alternative mailers may be setup
|
||||
| and used as needed; however, this mailer will be used by default.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'smtp'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers to be used while
|
||||
| sending an e-mail. You will specify which one you are using for your
|
||||
| mailers below. You are free to add additional mailers as required.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses",
|
||||
| "postmark", "log", "array", "failover"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all e-mails sent by your application to be sent from
|
||||
| the same address. Here, you may specify a name and address that is
|
||||
| used globally for all e-mails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Markdown Mail Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you are using Markdown based email rendering, you may configure your
|
||||
| theme and component paths here, allowing you to customize the design
|
||||
| of the emails. Or, you may simply stick with the Laravel defaults!
|
||||
|
|
||||
*/
|
||||
|
||||
'markdown' => [
|
||||
'theme' => 'default',
|
||||
|
||||
'paths' => [
|
||||
resource_path('views/vendor/mail'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
161
config/permission.php
Normal file
161
config/permission.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, //default 'role_id',
|
||||
'permission_pivot_key' => null, //default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false, if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true the package implements teams using the 'team_foreign_key'. If you want
|
||||
* the migrations to register the 'team_foreign_key', you must set this to true
|
||||
* before doing the migration. If you already did the migration then you must make a new
|
||||
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
|
||||
* 'model_has_permissions'(view the latest version of package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
||||
93
config/queue.php
Normal file
93
config/queue.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue API supports an assortment of back-ends via a single
|
||||
| API, giving you convenient access to each back-end using the same
|
||||
| syntax for every one. Here you may define a default connection.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'sync'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection information for each server that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with Laravel. You are free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => 'localhost',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control which database and table are used to store the jobs that
|
||||
| have failed. You may change them to any database / table you wish.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
67
config/sanctum.php
Normal file
67
config/sanctum.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort()
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. If this value is null, personal access tokens do
|
||||
| not expire. This won't tweak the lifetime of first-party sessions.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
|
||||
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
|
||||
],
|
||||
|
||||
];
|
||||
34
config/services.php
Normal file
34
config/services.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'mailgun' => [
|
||||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
'secret' => env('MAILGUN_SECRET'),
|
||||
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
];
|
||||
201
config/session.php
Normal file
201
config/session.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default session "driver" that will be used on
|
||||
| requests. By default, we will use the lightweight native driver but
|
||||
| you may specify any of the other wonderful drivers provided here.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to immediately expire on the browser closing, set that option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it is stored. All encryption will be run
|
||||
| automatically by Laravel and you can use the Session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the native session driver, we need a location where session
|
||||
| files may be stored. A default has been set for you but a different
|
||||
| location may be specified. This is only needed for file sessions.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table we
|
||||
| should use to manage the sessions. Of course, a sensible default is
|
||||
| provided for you; however, you are free to change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => 'sessions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While using one of the framework's cache driven session backends you may
|
||||
| list a cache store that should be used for these sessions. This value
|
||||
| must match with one of the application's configured cache "stores".
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the cookie used to identify a session
|
||||
| instance by ID. The name specified here will get used every time a
|
||||
| new session cookie is created by the framework for every driver.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application but you are free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => '/',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the domain of the cookie used to identify a session
|
||||
| in your application. This will determine which domains the cookie is
|
||||
| available to in your application. A sensible default has been set.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. You are free to modify this option if needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" since this is a secure default value.
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => 'lax',
|
||||
|
||||
];
|
||||
36
config/view.php
Normal file
36
config/view.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Storage Paths
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Most templating systems load templates from disk. Here you may specify
|
||||
| an array of paths that should be checked for your views. Of course
|
||||
| the usual Laravel view path has already been registered for you.
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
resource_path('views'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Compiled View Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines where all the compiled Blade templates will be
|
||||
| stored for your application. Typically, this is within the storage
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => env(
|
||||
'VIEW_COMPILED_PATH',
|
||||
realpath(storage_path('framework/views'))
|
||||
),
|
||||
|
||||
];
|
||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
69
database/factories/UserFactory.php
Normal file
69
database/factories/UserFactory.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Jetstream\Features;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function unverified()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'email_verified_at' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the user should have a personal team.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withPersonalTeam()
|
||||
{
|
||||
if (! Features::hasTeamFeatures()) {
|
||||
return $this->state([]);
|
||||
}
|
||||
|
||||
return $this->has(
|
||||
Team::factory()
|
||||
->state(function (array $attributes, User $user) {
|
||||
return ['name' => $user->name.'\'s Team', 'user_id' => $user->id, 'personal_team' => true];
|
||||
}),
|
||||
'ownedTeams'
|
||||
);
|
||||
}
|
||||
}
|
||||
41
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
41
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('paternal');
|
||||
$table->string('maternal')->nullable();
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone')->nullable()->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->foreignId('current_team_id')->nullable();
|
||||
$table->string('profile_photo_path', 2048)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->text('two_factor_secret')
|
||||
->after('password')
|
||||
->nullable();
|
||||
|
||||
$table->text('two_factor_recovery_codes')
|
||||
->after('two_factor_secret')
|
||||
->nullable();
|
||||
|
||||
if (Fortify::confirmsTwoFactorAuthentication()) {
|
||||
$table->timestamp('two_factor_confirmed_at')
|
||||
->after('two_factor_recovery_codes')
|
||||
->nullable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(array_merge([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
], Fortify::confirmsTwoFactorAuthentication() ? [
|
||||
'two_factor_confirmed_at',
|
||||
] : []));
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$teams = config('permission.teams');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
|
||||
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('description')->nullable();
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
|
||||
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign(PermissionRegistrar::$pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user