Compare commits

..

No commits in common. "cded6112ec03b1de9003c787bbddb79f9e625101" and "c6687c39716491a0d91fba1c21d4c84256d6b3b5" have entirely different histories.

6 changed files with 31 additions and 38 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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