FIX: Correcciones device y modulo
This commit is contained in:
parent
551ef38ffc
commit
82b7a179f5
@ -174,13 +174,16 @@ public function toggleStatus(int $id)
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
// Cambiar el status al valor opuesto
|
||||
$newStatus = !$module->status;
|
||||
|
||||
$module->update([
|
||||
'status' => !$module->status,
|
||||
'status' => $newStatus,
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
$module->refresh();
|
||||
|
||||
return ApiResponse::OK->response([
|
||||
'message' => $module->status
|
||||
? 'Módulo activado exitosamente'
|
||||
|
||||
@ -13,16 +13,16 @@ public function authorize(): bool
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$deviceId = $this->route('id');
|
||||
$deviceId = $this->route('device');
|
||||
|
||||
return [
|
||||
'brand' => ['sometimes', 'string', 'max:255'],
|
||||
'serie' => ['sometimes', 'string', 'unique:devices,serie,' . $deviceId, 'max:255'],
|
||||
'mac_address' => ['sometimes', 'string', 'unique:devices,mac_address,' . $deviceId, 'regex:/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/'],
|
||||
'module_id' => ['sometimes', 'exists:modules,id'],
|
||||
'user_id' => ['sometimes', 'array', 'min:1'],
|
||||
'brand' => ['nullable', 'string', 'max:255'],
|
||||
'serie' => ['nullable', 'string', 'unique:devices,serie,' . $deviceId, 'max:255'],
|
||||
'mac_address' => ['nullable', 'string', 'unique:devices,mac_address,' . $deviceId, 'regex:/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/'],
|
||||
'module_id' => ['nullable', 'exists:modules,id'],
|
||||
'user_id' => ['nullable', 'array'],
|
||||
'user_id.*' => ['exists:users,id'],
|
||||
'status' => ['sometimes', 'boolean'],
|
||||
'status' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -14,9 +14,10 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['nullable', 'string', 'max:255'],
|
||||
'municipality' => ['nullable', 'string', 'max:100'],
|
||||
'address' => ['nullable', 'string', 'max:255'],
|
||||
'name' => ['nullable', 'string', 'max:50'],
|
||||
'municipality_id' => ['nullable', 'integer', 'exists:municipalities,id'],
|
||||
'responsible_id' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'address' => ['nullable', 'string', 'max:50'],
|
||||
'colony' => ['nullable', 'string', 'max:100'],
|
||||
'cp' => ['nullable', 'string', 'max:10'],
|
||||
'longitude' => ['nullable', 'numeric', 'between:-180,180'],
|
||||
@ -28,15 +29,17 @@ public function rules(): array
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.string' => 'El nombre debe ser una cadena de texto',
|
||||
'name.max' => 'El nombre no debe superar los 255 caracteres',
|
||||
'municipality.string' => 'El municipio debe ser una cadena de texto',
|
||||
'municipality.max' => 'El municipio no debe superar los 100 caracteres',
|
||||
'address.string' => 'La dirección debe ser una cadena de texto',
|
||||
'address.max' => 'La dirección no debe superar los 255 caracteres',
|
||||
'colony.string' => 'La colonia debe ser una cadena de texto',
|
||||
'name.string' => 'El nombre debe ser texto',
|
||||
'name.max' => 'El nombre no debe superar los 50 caracteres',
|
||||
'municipality_id.integer' => 'El municipio debe ser un número entero',
|
||||
'municipality_id.exists' => 'El municipio seleccionado no existe',
|
||||
'responsible_id.integer' => 'El responsable debe ser un número entero',
|
||||
'responsible_id.exists' => 'El responsable seleccionado no existe',
|
||||
'address.string' => 'La dirección debe ser texto',
|
||||
'address.max' => 'La dirección no debe superar los 50 caracteres',
|
||||
'colony.string' => 'La colonia debe ser texto',
|
||||
'colony.max' => 'La colonia no debe superar los 100 caracteres',
|
||||
'cp.string' => 'El código postal debe ser una cadena de texto',
|
||||
'cp.string' => 'El código postal debe ser texto',
|
||||
'cp.max' => 'El código postal no debe superar los 10 caracteres',
|
||||
'longitude.numeric' => 'La longitud debe ser un número',
|
||||
'longitude.between' => 'La longitud debe estar entre -180 y 180',
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
Route::post('cancelacion/cancelar', [CancellationController::class, 'cancelarConstancia']);
|
||||
|
||||
//Rutas de Modulos
|
||||
Route::patch('module/{id}/toggle-status', [ModuleController::class, 'toggleStatus']);
|
||||
Route::resource('module', ModuleController::class);
|
||||
|
||||
//Rutas de Municipios
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user