|  |  | @ -59,6 +59,17 @@ class TiposLicenciasController extends Controller | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public function store(Request $request) | 
			
		
	
		
			
				
					|  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |         // Verificar si ya existe un tipo de licencia con el mismo nombre | 
			
		
	
		
			
				
					|  |  |  |         $existe = tiposLicencias::where('tipoLicencia', $request->tipoLicencia) | 
			
		
	
		
			
				
					|  |  |  |             ->where('eliminado', 1) | 
			
		
	
		
			
				
					|  |  |  |             ->exists(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if ($existe) { | 
			
		
	
		
			
				
					|  |  |  |             return redirect()->route('tiposLicencias.create') | 
			
		
	
		
			
				
					|  |  |  |                 ->with('error', 'Ya existe un tipo de licencia con el nombre "' . $request->tipoLicencia . '". Por favor, ingrese un nombre diferente.') | 
			
		
	
		
			
				
					|  |  |  |                 ->withInput(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         $tipoLicencia = new TiposLicencias(); | 
			
		
	
		
			
				
					|  |  |  |         $tipoLicencia->tipoLicencia = $request->tipoLicencia; | 
			
		
	
		
			
				
					|  |  |  |         $tipoLicencia->eliminado = 1; | 
			
		
	
	
		
			
				
					|  |  | @ -81,6 +92,18 @@ class TiposLicenciasController extends Controller | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public function update(Request $request, $id) | 
			
		
	
		
			
				
					|  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |         // Verificar si ya existe otro tipo de licencia con el mismo nombre | 
			
		
	
		
			
				
					|  |  |  |         $existe = tiposLicencias::where('tipoLicencia', $request->tipoLicencia) | 
			
		
	
		
			
				
					|  |  |  |             ->where('id', '!=', $id) | 
			
		
	
		
			
				
					|  |  |  |             ->where('eliminado', 1) | 
			
		
	
		
			
				
					|  |  |  |             ->exists(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if ($existe) { | 
			
		
	
		
			
				
					|  |  |  |             return redirect()->route('tiposLicencias.edit', $id) | 
			
		
	
		
			
				
					|  |  |  |                 ->with('error', 'Ya existe un tipo de licencia con el nombre "' . $request->tipoLicencia . '". Por favor, ingrese un nombre diferente.') | 
			
		
	
		
			
				
					|  |  |  |                 ->withInput(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         $tipoLicencia = TiposLicencias::findOrFail($id); | 
			
		
	
		
			
				
					|  |  |  |         $tipoLicencia->tipoLicencia = $request->tipoLicencia; | 
			
		
	
		
			
				
					|  |  |  |         if ($request->has('eliminado')) { | 
			
		
	
	
		
			
				
					|  |  | 
 |