Correccion actas (validator)
This commit is contained in:
parent
453a6f9276
commit
a215a8412d
@ -5,19 +5,28 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Acta;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ActaController extends Controller
|
||||
{
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
$validator = Validator::make($request->all(), [
|
||||
'descripcion' => 'required',
|
||||
'fecha' => 'required',
|
||||
'id_estandar' => 'required|exists:estandars,id',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Se necesita llenar todos los campos',
|
||||
'data' => $validator->errors()
|
||||
], 400);
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
if (!($user->isAdmin() or $user->isEncargadoEstandar($request->id_estandar))) {
|
||||
return response()->json([
|
||||
@ -69,7 +78,7 @@ public function listActas()
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request = Validator::make($request->all(), [
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id' => 'required|exists:actas,id',
|
||||
'descripcion' => 'present',
|
||||
'fecha' => 'present',
|
||||
@ -85,11 +94,11 @@ public function update(Request $request)
|
||||
}
|
||||
|
||||
|
||||
if ($request->fails()) {
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Se produjo un error al actualizar la acta',
|
||||
'data' => $request->errors()
|
||||
'data' => $validator->errors()
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user