/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Specialist::find();
     $query->joinWith('statusgroup');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['statusgroup'] = ['asc' => ['status.name' => SORT_ASC], 'desc' => ['status.name' => SORT_DESC]];
     $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(['id_specialist' => $this->id_specialist, 'create_day' => $this->create_day, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name_specialist', $this->name_specialist])->andFilterWhere(['like', 'status.name', $this->statusgroup]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSpecialist()
 {
     return $this->hasOne(Specialist::className(), ['id_specialist' => 'id_specialist']);
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSpecialists()
 {
     return $this->hasMany(Specialist::className(), ['status' => 'id']);
 }
 /**
  * Finds the Specialist model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Specialist the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Specialist::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 5
0
use yii\helpers\ArrayHelper;
use backend\models\Specialist;
use backend\models\Status;
/* @var $this yii\web\View */
/* @var $model backend\models\SpecialistSick */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="specialist-sick-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
echo $form->field($model, 'id_specialist')->dropDownList(ArrayHelper::map(Specialist::find()->all(), 'id_specialist', 'name_specialist'), ['prompt' => 'Select specialist']);
?>

    <?php 
echo $form->field($model, 'name_sick')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'create_day')->textInput();
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ArrayHelper::map(Status::find()->all(), 'id', 'name'), []);
?>

    <div class="form-group">