public static function delete($id) { $staff = Staff::find($id); if (!is_null($staff->first())) { return $staff->delete(); } else { return false; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Staff::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['staff_id' => $this->staff_id, 'position_id' => $this->position_id, 'department_id' => $this->department_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Staff::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'fechaNacimiento' => $this->fechaNacimiento]); $query->andFilterWhere(['like', 'dpto_nombre', $this->dpto_nombre])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido1', $this->apellido1])->andFilterWhere(['like', 'apellido2', $this->apellido2])->andFilterWhere(['like', 'rut', $this->rut])->andFilterWhere(['like', 'cargo', $this->cargo])->andFilterWhere(['like', 'rol', $this->rol])->andFilterWhere(['like', 'domicilio', $this->domicilio])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'correo', $this->correo]); return $dataProvider; }
public function GetStaffName($id) { $name = ""; $model = new Staff(); $model = Staff::find()->where(['formalemail' => $id])->one(); $name = $model->name; return $name; }
use yii\helpers\Html; //use yii\widgets\ActiveForm; use kartik\widgets\ActiveForm; use kartik\widgets\DatePicker; use app\models\RequestType; use yii\helpers\ArrayHelper; use app\models\Staff; /* @var $this yii\web\View */ /* @var $model app\models\RequestDic */ /* @var $form yii\widgets\ActiveForm */ ?> <?php $RequestType = RequestType::find()->all(); $arraytype = ArrayHelper::map($RequestType, 'type_id', 'request_name'); $Staff = Staff::find()->all(); $arrayStaff = ArrayHelper::map($Staff, 'staff_id', 'name'); if (isset($erros)) { echo Alert::widget(['options' => ['class' => 'alert-info'], 'body' => $erros]); } ?> <div class="request-dic-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'req_type_id')->dropDownList($arraytype, ['prompt' => '--Select--']); ?>
public function destroy($id) { Staff::find($id)->delete(); return redirect('staffs'); }
public function updateView($id) { $staff = Staff::find($id); $data = ['page_title' => 'Staff', 'panel_title' => 'Form Edit', 'form_url' => '/dash/setting/staff/update', 'form_status' => 'edit', 'staff' => $staff]; return View::make('staff.form', $data); }