Esempio n. 1
0
 public function search($params)
 {
     $query = Music::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP]);
     return $dataProvider;
 }
Esempio n. 2
0
 public static function getMusic($data)
 {
     $query = Music::find()->andWhere('deleted = 0')->limit(!empty($data['limit']) ? $data['limit'] : 20)->orderBy('id DESC');
     if (!empty($data['userId'])) {
         $query->andWhere('user_id = :user_id', [':user_id' => $data['userId']]);
     }
     if (!empty($data['artistOrTitle'])) {
         $artistOrTitle = '%' . $data['artistOrTitle'] . '%';
         $query->andWhere('artist LIKE :value OR title LIKE :value', [':value' => $artistOrTitle]);
     }
     return $query->all();
 }
 public function search($params)
 {
     $query = Music::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['Id' => SORT_ASC, 'name' => SORT_ASC]]);
     $query->andFilterWhere([music::tableName() . '.status' => '0']);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdOn' => $this->createdOn, 'status' => $this->status, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'searchAlias', $this->searchAlias]);
     return $dataProvider;
 }
 /**
  * Finds the Music model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Music the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Music::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMusic()
 {
     return $this->hasMany(Music::className(), ['Id' => 'musicId'])->via('resMaps');
 }
Esempio n. 6
0
 public function getLastAudio()
 {
     return Music::getMusic(['userId' => $this->id]);
 }
Esempio n. 7
0
 public function getSounds()
 {
     return $this->hasMany(Music::className(), ['id' => 'entity_2_id'])->viaTable(EntityLink::tableName(), ['entity_1_id' => 'id'], function ($query) {
         $query->onCondition(['entity_1' => Item::THIS_ENTITY, 'entity_2' => Music::THIS_ENTITY]);
     });
 }
Esempio n. 8
0
 public function actionSave()
 {
     $thisUser = User::thisUser();
     $id = Yii::$app->request->post('id');
     $music = Music::findOne($id);
     if ($music->user_id == $thisUser->id) {
         $music->artist = Yii::$app->request->post('artist');
         $music->title = Yii::$app->request->post('title');
         $music->save();
     }
     return json_encode(['musicHtml' => SoundWidget::widget(['music' => $music]), 'musicId' => $music->id]);
 }