public function getDelete(Unidades $unidades) { $oldunidades = $unidades->id; if ($unidades->delete(['id'])) { $materias = Materias::where('unidad', '=', $oldunidades)->get(); foreach ($materias as $materia) { $materia->unidad = 0; $materia->update(); } return Redirect::back()->with('msg', 'Unidad eliminada con éxito.')->with('class', 'success'); } else { return Redirect::back()->with('msg', '¡Algo salió mal! La unidad no pudo ser eliminada.')->with('class', 'error'); } }
public function getEdit(Materias $materias) { $unidades = Unidades::all(); return View::make('dashboard/materias/edit', compact('materias', 'unidades')); }
<?php echo $form->textFieldGroup($model,'costo_unitario',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>38)))); ?> </td> <td> <?php echo $form->textFieldGroup($model,'cantidad_adquirida',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5')))); ?> </td> <td> <?php echo $form->select2Group($model, 'unidad_id', array( 'wrapperHtmlOptions' => array( 'class' => 'col-sm-5', ), 'label'=>'Unidad', 'widgetOptions' => array( 'asDropDownList' => true, 'data' => CHtml::listData(Unidades::model()->findAll(),'unidad_id', 'nombre'), 'htmlOptions'=>array('id'=>'unidad',), 'options' => array( //'tags' => array('clever', 'is', 'better', 'clevertech'), 'placeholder' => 'Seleccionar unidad', // 'width' => '40%', 'tokenSeparators' => array(',', ' ') ) ) ) ); ?> </td> <td> <?php //echo $form->textFieldGroup($model,'iva_id',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5'))));
public function getUnidad() { $eleccion = Input::get('eleccion'); $materias = Materias::where('id', '=', $eleccion)->pluck('unidad'); $unidades = Unidades::where('id', '=', $materias)->get(); return Response::json($unidades); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Unidades::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }