planes Show DataBaseSeeders

This commit is contained in:
AlexisAH 2022-08-01 23:44:21 -05:00
parent 8f44e41850
commit 0445fab2dd
33 changed files with 1549 additions and 32 deletions

File diff suppressed because it is too large Load Diff

BIN
.vs/PIS-proyect/v17/.suo Normal file

Binary file not shown.

3
.vs/ProjectSettings.json Normal file
View File

@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}

10
.vs/VSWorkspaceState.json Normal file
View File

@ -0,0 +1,10 @@
{
"ExpandedNodes": [
"",
"\\app",
"\\app\\Models",
"\\app\\Providers"
],
"SelectedNode": "\\app\\Providers\\AppServiceProvider.php",
"PreviewInSolutionExplorer": false
}

3
.vs/phptasks.json Normal file
View File

@ -0,0 +1,3 @@
{
"tasks": []
}

BIN
.vs/slnx.sqlite Normal file

Binary file not shown.

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\AccionesMejoras;
use Illuminate\Http\Request;
class AccionesMejorasController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$accion = new AccionesMejoras();
$accion->estandar_id = $request->estandar_id;
$accion->descripcion = $request->descripcion;
$accion->save();
return response()([
"status" => 1,
"message" => "accion creada exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$accion = AccionesMejoras::find($request->id);
$accion->descripcion = $request->descripcion;
$accion->save();
return response([
"status" => 1,
"message" => "accion actualizada exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(AccionesMejoras::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = AccionesMejoras::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "!accion eliminada con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro la accion o no esta autorizado",
],404);
}
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\CausasRaices;
use Illuminate\Http\Request;
class CausasRaicesController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$causa = new CausasRaices();
$causa->estandar_id = $request->estandar_id;
$causa->descripcion = $request->descripcion;
$causa->save();
return response()([
"status" => 1,
"message" => "Causa creada exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$causa = CausasRaices::find($request->id);
$causa->descripcion = $request->descripcion;
$causa->save();
return response([
"status" => 1,
"message" => "Causa actualizada exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(CausasRaices::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = CausasRaices::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "!Causa eliminada con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro la causa o no esta autorizado",
],404);
}
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Fuentes;
use Illuminate\Http\Request;
class FuentesController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$fuente = new Fuentes();
$fuente->estandar_id = $request->estandar_id;
$fuente->descripcion = $request->descripcion;
$fuente->save();
return response()([
"status" => 1,
"message" => "Fuente creada exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$fuente = Fuentes::find($request->id);
$fuente->descripcion = $request->descripcion;
$fuente->save();
return response([
"status" => 1,
"message" => "fuente actualizada exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(Fuentes::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = Fuentes::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "!Fuente eliminada con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro la fuente o no esta autorizado",
],404);
}
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Observaciones;
use Illuminate\Http\Request;
class ObservacionesController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$observacion = new Observaciones();
$observacion->estandar_id = $request->estandar_id;
$observacion->descripcion = $request->descripcion;
$observacion->save();
return response()([
"status" => 1,
"message" => "Observacion creada exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$observacion = Observaciones::find($request->id);
$observacion->descripcion = $request->descripcion;
$observacion->save();
return response([
"status" => 1,
"message" => "Observacion actualizada exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(Observaciones::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = Observaciones::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "!Observacion eliminada con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro la Observacion o no esta autorizado",
],404);
}
}
}

View File

@ -24,31 +24,31 @@ public function createPlan(Request $request){
"estandar_id"=> "required|integer", "estandar_id"=> "required|integer",
"nombre"=>"required|max:255", "nombre"=>"required|max:255",
"codigo"=> "required|max:11", "codigo"=> "required|max:11",
"fuentes"=>"required", /*"fuentes"=>"required",
"fuentes.*.descripcion"=> "required", "fuentes.*.descripcion"=> "required",
"problemas_oportunidades"=>"required", "problemas_oportunidades"=>"required",
"problemas_oportunidades.*.descripcion"=> "required", "problemas_oportunidades.*.descripcion"=> "required",
"causas_raices"=>"required", "causas_raices"=>"required",
"causas_raices.*.descripcion"=> "required", "causas_raices.*.descripcion"=> "required",*/
"oportunidad_plan"=>"required|max:255", "oportunidad_plan"=>"required|max:255",
"acciones_mejoras"=>"required", /*"acciones_mejoras"=>"required",
"acciones_mejoras.*.descripcion"=> "required", "acciones_mejoras.*.descripcion"=> "required",*/
"semestre_ejecucion"=>"required|max:7", "semestre_ejecucion"=>"required|max:7",
"duracion"=> "required|integer", "duracion"=> "required|integer",
"recursos"=>"required", /*"recursos"=>"required",
"recursos.*.descripcion"=> "required", "recursos.*.descripcion"=> "required",
"metas"=>"required", "metas"=>"required",
"metas.*.descripcion"=> "required", "metas.*.descripcion"=> "required",
"responsables"=>"required", "responsables"=>"required",
"responsables.*.nombre"=> "required", "responsables.*.nombre"=> "required",
"observaciones"=>"required", "observaciones"=>"required",
"observaciones.*.descripcion"=> "required", "observaciones.*.descripcion"=> "required",*/
"estado"=> "required|max:30", "estado"=> "required|max:30",
"evidencias_planes_mejoras"=>"required", /*"evidencias_planes_mejoras"=>"required",
"evidencias_planes_mejoras.*.codigo"=> "required", "evidencias_planes_mejoras.*.codigo"=> "required",
"evidencias_planes_mejoras.*.denominacion"=> "required", "evidencias_planes_mejoras.*.denominacion"=> "required",
"evidencias_planes_mejoras.*.encargado_id"=> "required", "evidencias_planes_mejoras.*.encargado_id"=> "required",
"evidencias_planes_mejoras.*.adjunto"=> "required", "evidencias_planes_mejoras.*.adjunto"=> "required",*/
"evaluacion_eficacia"=> "required|boolean", "evaluacion_eficacia"=> "required|boolean",
"avance"=> "required|integer", "avance"=> "required|integer",
]); ]);
@ -190,9 +190,17 @@ public function deletePlan($id){
public function showPlan($id){ public function showPlan($id){
if(plan::where("id",$id)->exists()){ if(plan::where("id",$id)->exists()){
$plan = plan::find($id); $plan = plan::find($id);
$plan->fuentes = Fuentes::where("id_plan",$id)->get();
$plan->problemas_oportunidades = ProblemasOportunidades::where("id_plan",$id)->get();
$plan->causas_raices = CausasRaices::where("id_plan",$id)->get();
$plan->acciones_mejoras = AccionesMejoras::where("id_plan",$id)->get();
$plan->recursos = Recursos::where("id_plan",$id)->get();
$plan->metas = Metas::where("id_plan",$id)->get();
$plan->observaciones = Observaciones::where("id_plan",$id)->get();
$plan->evidencias_planes_mejoras = Evidencias::where("id_plan",$id)->get();
return response([ return response([
"status" => 1, "status" => 1,
"message" => "!plan", "message" => "!Plan de mejora encontrado",
"data" => $plan, "data" => $plan,
]); ]);
} }

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\ProblemasOportunidades;
use Illuminate\Http\Request;
class ProblemasOportunidadesController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$problema = new ProblemasOportunidades();
$problema->estandar_id = $request->estandar_id;
$problema->descripcion = $request->descripcion;
$problema->save();
return response()([
"status" => 1,
"message" => "problema creada exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$problema = ProblemasOportunidades::find($request->id);
$problema->descripcion = $request->descripcion;
$problema->save();
return response([
"status" => 1,
"message" => "problema actualizada exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(ProblemasOportunidades::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = ProblemasOportunidades::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "problema eliminada con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro el problema o no esta autorizado",
],404);
}
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Recursos;
use Illuminate\Http\Request;
class RecursosController extends Controller
{
public function create(Request $request) {
$request->validate([
"estandar_id"=> "required|integer",
"descripcion"=> "required",
]);
$recurso = new Recursos();
$recurso->estandar_id = $request->estandar_id;
$recurso->descripcion = $request->descripcion;
$recurso->save();
return response()([
"status" => 1,
"message" => "Recurso creado exitosamente"
]);
}
public function update(Request $request){
$request->validate([
"id"=> "required|integer",
"descripcion"=> "required"
]);
$recurso = Recursos::find($request->id);
$recurso->descripcion = $request->descripcion;
$recurso->save();
return response([
"status" => 1,
"message" => "Recurso actualizado exitosamente",
]);
}
public function delete($id)
{
$id_user = auth()->user()->id;
if(Recursos::where(["id"=>$id,"id_user"=>$id_user])->exists()){
$plan = Recursos::where(["id"=>$id,"id_user"=>$id_user])->first();
$plan->delete();
return response([
"status" => 1,
"message" => "!Recurso eliminado con éxito!",
],200);
}
else{
return response([
"status" => 0,
"message" => "!No se encontro el Recurso o no esta autorizado",
],404);
}
}
}

View File

@ -8,7 +8,7 @@
class AccionesMejoras extends Model class AccionesMejoras extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='acciones_mejoras'; protected $table ='acciones_mejoras';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class CausasRaices extends Model class CausasRaices extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='causas_raices'; protected $table ='causas_raices';
protected $fillable = [ protected $fillable = [

View File

@ -9,7 +9,7 @@ class Estandar extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='estandars'; protected $table ='estandars';
protected $fillable = [ protected $fillable = [
'name', 'name',

View File

@ -9,7 +9,7 @@ class Evidencias extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='evidencias'; protected $table ='evidencias';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class Fuentes extends Model class Fuentes extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='fuentes'; protected $table ='fuentes';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class Metas extends Model class Metas extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='metas'; protected $table ='metas';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class Observaciones extends Model class Observaciones extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='observaciones'; protected $table ='observaciones';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class ProblemasOportunidades extends Model class ProblemasOportunidades extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='problemas_oportunidades'; protected $table ='problemas_oportunidades';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class Recursos extends Model class Recursos extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='recursos'; protected $table ='recursos';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class Responsables extends Model class Responsables extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='responsables'; protected $table ='responsables';
protected $fillable = [ protected $fillable = [

View File

@ -8,7 +8,7 @@
class plan extends Model class plan extends Model
{ {
use HasFactory; use HasFactory;
public $timestamps = false; public $timestamps = true;
protected $table ='plans'; protected $table ='plans';
protected $fillable = [ protected $fillable = [

View File

@ -0,0 +1,25 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Estandar>
*/
class EstandarFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'name' => $this->faker->name(),
'id_user' =>$this,
];
}
}

View File

@ -19,10 +19,9 @@ public function definition()
{ {
return [ return [
'name' => $this->faker->name(), 'name' => $this->faker->name(),
'lastname' => $this->faker->lastname(),
'email' => $this->faker->unique()->safeEmail(), 'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(), 'password' => $this, // password
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
]; ];
} }

View File

@ -16,6 +16,7 @@ public function up()
Schema::create('estandars', function (Blueprint $table) { Schema::create('estandars', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); //cambiar el name por nombre $table->string('name'); //cambiar el name por nombre
$table->timestamps();
//$table->foreign('id_user')->references('id')->on('users'); //$table->foreign('id_user')->references('id')->on('users');
$table->foreignId('id_user') $table->foreignId('id_user')
->constrained('users'); ->constrained('users');

View File

@ -27,7 +27,7 @@ public function up()
->constrained('estandars'); ->constrained('estandars');
$table->foreignId('id_user') $table->foreignId('id_user')
->constrained('users'); ->constrained('users');
$table->timestamps();
}); });
} }

View File

@ -23,7 +23,7 @@ public function up()
$table->foreignId('id_plan') $table->foreignId('id_plan')
->constrained('plans') ->constrained('plans')
->onDelete('cascade'); ->onDelete('cascade');
$table->timestamps();
}); });
} }

View File

@ -4,6 +4,7 @@
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
@ -14,11 +15,73 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() public function run()
{ {
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([ \App\Models\User::factory()->create([
// 'name' => 'Test User', "name"=>"Alexis",
// 'email' => 'test@example.com', "lastname"=>"Arroyo",
// ]); "email"=>"aarroyoh@unsa.edu.pe",
"password"=>Hash::make("luisangel"),
]);
\App\Models\User::factory()->create([
"name"=>"Fernando",
"lastname"=>"Araoz",
"email"=>"faraoz@unsa.edu.pe",
"password"=>Hash::make("123456"),
]);
\App\Models\User::factory()->create([
"name"=>"Jhonatan",
"lastname"=>"Acuña",
"email"=>"jacuna@unsa.edu.pe",
"password"=>Hash::make("123456"),
]);
\App\Models\User::factory()->create([
"name"=>"Carlos",
"lastname"=>"Gonzales",
"email"=>"cgonzalesmo@unsa.edu.pe",
"password"=>Hash::make("123456"),
]);
\App\Models\User::factory()->create([
"name"=>"Christian",
"lastname"=>"Sullca",
"email"=>"csullcap@unsa.edu.pe",
"password"=>Hash::make("123456"),
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-1 Propositos Articulados",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-2 Participacion de los Grupos de Interes",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-3 Revision Periodica de las Politicas y Objetivos",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-4 Sostenibilidad",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-5 Pertinencia del Perfil de Egreso",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-6 Revision del Perfil de Egreso",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-7 Sistema de Gestion de la Calidad",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-8 Planes de Mejora",
"id_user"=>1,
]);
\App\Models\Estandar::factory()->create([
"name"=>"E-9 Planes de Mejora",
"id_user"=>1,
]);
} }
} }

View File

@ -5,6 +5,14 @@
use App\Http\Controllers\Api\UserController; use App\Http\Controllers\Api\UserController;
use App\Http\Controllers\Api\EstandarController; use App\Http\Controllers\Api\EstandarController;
use App\Http\Controllers\Api\PlanController; use App\Http\Controllers\Api\PlanController;
use App\Http\Controllers\Api\MetasController;
use App\Http\Controllers\Api\AccionesMejorasController;
use App\Http\Controllers\Api\CausasRaicesController;
use App\Http\Controllers\Api\FuentesController;
use App\Http\Controllers\Api\ObservacionesController;
use App\Http\Controllers\Api\ProblemasOportunidadesController;
use App\Http\Controllers\Api\RecursosController;
Route::post('register', [UserController::class, 'register']); Route::post('register', [UserController::class, 'register']);
Route::post('login', [UserController::class, 'login']); Route::post('login', [UserController::class, 'login']);
@ -26,9 +34,42 @@
Route::get('plan',[PlanController::class,'listPlan']); Route::get('plan',[PlanController::class,'listPlan']);
Route::get('plan/{id}',[PlanController::class,'showPlan']); Route::get('plan/{id}',[PlanController::class,'showPlan']);
Route::delete('plan/{id}',[PlanController::class,'deletePlan']); Route::delete('plan/{id}',[PlanController::class,'deletePlan']);
#Route::put('plan/{id}',[PlanController::class,'updatePlan']); #Route::put('/{id}',[Controller::class,'update']);
//rutas metas
Route::post('meta',[MetasController::class,'create']);
Route::put('meta',[MetasController::class,'update']);
Route::delete('meta/{id}',[MetasController::class,'delete']);
//rutas accionesmejoras
Route::post('accionmejora',[AccionesMejorasController::class,'create']);
Route::put('accionmejora',[AccionesMejorasController::class,'update']);
Route::delete('accionmejora/{id}',[AccionesMejorasController::class,'delete']);
//rutas fuentes
Route::post('fuente',[FuentesController::class,'create']);
Route::put('fuente',[FuentesController::class,'update']);
Route::delete('fuente/{id}',[FuentesController::class,'delete']);
//rutas observaciones
Route::post('observacion',[ObservacionesController::class,'create']);
Route::put('observacion',[ObservacionesController::class,'update']);
Route::delete('observacion/{id}',[ObservacionesController::class,'delete']);
//rutas problemas
Route::post('problema',[ProblemasOportunidadesController::class,'create']);
Route::put('problema',[ProblemasOportunidadesController::class,'update']);
Route::delete('problema/{id}',[ProblemasOportunidadesController::class,'delete']);
//rutas recursos
Route::post('recurso',[RecursosController::class,'create']);
Route::put('recurso',[RecursosController::class,'update']);
Route::delete('recurso/{id}',[RecursosController::class,'delete']);
//rutas casuasraiz
Route::post('causa',[CausasRaicesController::class,'create']);
Route::put('causa',[CausasRaicesController::class,'update']);
Route::delete('causa/{id}',[CausasRaicesController::class,'delete']);