Compare commits

..

11 Commits

Author SHA1 Message Date
cgonzalesmo
cded6112ec Correcion actas (fecha y id_estandar) 2022-12-22 22:59:53 -05:00
cgonzalesmo
a215a8412d Correccion actas (validator) 2022-12-22 22:44:29 -05:00
Christian Dacid Sullca Puma
453a6f9276 actas controller update fix 2022-12-22 22:34:27 -05:00
cgonzalesmo
e148efa2bc Update Actas (correcion errores) 2022-12-17 13:30:20 -05:00
Christian Dacid Sullca Puma
23d81badb9 Merge branch 'master' of https://github.com/csullcap/PIS-proyect 2022-12-16 06:29:42 -05:00
Christian Dacid Sullca Puma
a3e4cf9387 modificacion entidad actas 2022-12-16 06:29:23 -05:00
cgonzalesmo
085a8e48a2 Evidencias -> Update 3.0
Signed-off-by: cgonzalesmo <cgonzalesmo@unsa.edu.pe>
2022-12-14 23:45:35 -05:00
cgonzalesmo
18cb80fe26 Evidencias -> Update 2.0
Signed-off-by: cgonzalesmo <cgonzalesmo@unsa.edu.pe>
2022-12-14 23:40:10 -05:00
cgonzalesmo
f49601ac1a Merge branch 'master' of https://github.com/csullcap/PIS-proyect 2022-12-14 23:10:30 -05:00
cgonzalesmo
1958f68859 Evidencia -> Update denominacion file
Signed-off-by: cgonzalesmo <cgonzalesmo@unsa.edu.pe>
2022-12-14 23:10:28 -05:00
Christian Dacid Sullca Puma
eea4ce9c19 modificacion .gitignore 2022-12-14 22:37:37 -05:00
6 changed files with 38 additions and 31 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ yarn-error.log
/.vscode /.vscode
/.vsc /.vsc
/.vs /.vs
/storage/app/evidencias

View File

@ -5,25 +5,25 @@
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Acta; use App\Models\Acta;
use Dotenv\Validator; use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Validator;
class ActaController extends Controller class ActaController extends Controller
{ {
public function create(Request $request) public function create(Request $request)
{ {
$request = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'titulo' => 'required', 'descripcion' => 'required',
'fecha' => 'required', 'fecha' => 'required',
'id_estandar' => 'required|exists:estandars,id', 'id_estandar' => 'required|exists:estandars,id',
'file' => 'required',
]); ]);
if ($request->fails()) { if ($validator->fails()) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
'message' => 'Se necesita llenar todos los campos', 'message' => 'Se necesita llenar todos los campos',
'data' => $request->errors() 'data' => $validator->errors()
], 400); ], 400);
} }
@ -34,12 +34,13 @@ public function create(Request $request)
'message' => 'No tienes permisos para crear una acta', 'message' => 'No tienes permisos para crear una acta',
], 401); ], 401);
} }
$acta = new Acta(); $acta = new Acta();
$acta->titulo = $request->titulo;
$acta->fecha = $request->fecha;
$acta->id_estandar = $request->id_estandar; $acta->id_estandar = $request->id_estandar;
$acta->file = $request->file; $acta->fecha = $request->fecha;
$acta->descripcion = $request->descripcion;
$acta->save(); $acta->save();
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'message' => 'Acta creada', 'message' => 'Acta creada',
@ -75,16 +76,16 @@ public function listActas()
], 200); ], 200);
} }
public function update(Request $request, $id) public function update(Request $request)
{ {
$request = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'titulo' => 'present', 'id' => 'required|exists:actas,id',
'fecha' => 'present', 'descripcion' => 'present',
'id_estandar' => 'present|exists:estandars,id', 'fecha' => 'sometimes',
'file' => 'present', 'id_estandar' => 'sometimes|exists:estandars,id',
]); ]);
$acta = Acta::find($id); $acta = Acta::find($request->id);
if (!$acta) { if (!$acta) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
@ -93,11 +94,11 @@ public function update(Request $request, $id)
} }
if ($request->fails()) { if ($validator->fails()) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
'message' => 'Se produjo un error al actualizar la acta', 'message' => 'Se produjo un error al actualizar la acta',
'data' => $request->errors() 'data' => $validator->errors()
], 400); ], 400);
} }
@ -109,10 +110,9 @@ public function update(Request $request, $id)
], 401); ], 401);
} }
$acta->titulo = isset($request->titulo) ? $request->titulo : $acta->titulo; $acta->descripcion = isset($request->descripcion) ? $request->descripcion : $acta->descripcion;
$acta->fecha = isset($request->fecha) ? $request->fecha : $acta->fecha; $acta->fecha = isset($request->fecha) ? $request->fecha : $acta->fecha;
$acta->id_estandar = isset($request->id_estandar) ? $request->id_estandar : $acta->id_estandar; $acta->id_estandar = isset($request->id_estandar) ? $request->id_estandar : $acta->id_estandar;
$acta->file = isset($request->file) ? $request->file : $acta->file;
$acta->save(); $acta->save();
return response()->json([ return response()->json([

View File

@ -30,9 +30,13 @@ public function create(Request $request)
$evidencia = new Evidencias(); $evidencia = new Evidencias();
$evidencia->id_plan = $request->id_plan; $evidencia->id_plan = $request->id_plan;
$evidencia->codigo = $plan->codigo; $evidencia->codigo = $plan->codigo;
$evidencia->denominacion = $request->denominacion; $evidencia->denominacion = $request->denominacion.'.'.$request->adjunto->extension();
error_log($request->denominacion); $path = $request->adjunto->storePubliclyAs(
$path = $request->adjunto->store('evidencias'); 'evidencias',
$request->adjunto->getClientOriginalName()
);
error_log($path);
$evidencia->adjunto = $path; $evidencia->adjunto = $path;
$evidencia->id_user = $id_user->id; $evidencia->id_user = $id_user->id;
$evidencia->save(); $evidencia->save();
@ -93,8 +97,11 @@ public function update(Request $request)
$plan = plan::find($evidencia->id_plan); $plan = plan::find($evidencia->id_plan);
if ($id_user->isCreadorPlan($plan->id) or $id_user->isAdmin()) { if ($id_user->isCreadorPlan($plan->id) or $id_user->isAdmin()) {
$evidencia->codigo = $request->codigo; $evidencia->codigo = $request->codigo;
$evidencia->denominacion = $request->denominacion; $evidencia->denominacion = $request->denominacion.$request->adjunto->extension();
$path = $request->adjunto->store('evidencias'); $path = $request->adjunto->storePubliclyAs(
'evidencias',
$request->adjunto->getClientOriginalName()
);
$evidencia->adjunto = $path; $evidencia->adjunto = $path;
$evidencia->save(); $evidencia->save();

View File

@ -12,9 +12,8 @@ class Acta extends Model
protected $table = 'actas'; protected $table = 'actas';
protected $fillable = [ protected $fillable = [
'titulo', 'descripcion',
'fecha', 'fecha'
'file',
]; ];
public function estandar() public function estandar()

View File

@ -18,10 +18,9 @@ public function up()
$table->id(); $table->id();
$table->date('fecha'); $table->date('fecha');
$table->string('titulo', 255); $table->mediumText('descripcion');
$table->foreignId('id_estandar') $table->foreignId('id_estandar')
->constrained('estandars'); ->constrained('estandars');
$table->string('file', 255);
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -19,6 +19,7 @@
use App\Http\Controllers\Api\EvidenciasController; use App\Http\Controllers\Api\EvidenciasController;
use App\Http\Controllers\Api\LoginController; use App\Http\Controllers\Api\LoginController;
use App\Http\Controllers\Api\NarrativasController; use App\Http\Controllers\Api\NarrativasController;
use App\Http\Controllers\Api\ActaController;
//Rutas de Auth //Rutas de Auth
Route::post('login', [LoginController::class, 'login'])->name('login'); Route::post('login', [LoginController::class, 'login'])->name('login');
@ -126,7 +127,7 @@
//ruta Actas //ruta Actas
Route::post('acta', [ActaController::class, 'create']); Route::post('acta', [ActaController::class, 'create']);
Route::get('acta/{id}', [ActaController::class, 'showActa'])->where('id', '[0-9]+'); Route::get('acta/{id}', [ActaController::class, 'showActa'])->where('id', '[0-9]+');
Route::put('acta/{id}', [ActaController::class, 'update'])->where('id', '[0-9]+'); Route::put('acta', [ActaController::class, 'update'])->where('id', '[0-9]+');
Route::delete('acta/{id}', [ActaController::class, 'delete'])->where('id', '[0-9]+'); Route::delete('acta/{id}', [ActaController::class, 'delete'])->where('id', '[0-9]+');
Route::get('acta', [ActaController::class, 'listActas']); Route::get('acta', [ActaController::class, 'listActas']);
}); });