/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Prints::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'timer' => $this->timer]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'descriptions', $this->descriptions]); return $dataProvider; }
public function getImageMergePrint($print_id) { /** * @var Prints $print */ $print = Prints::find()->where('id=:id', [':id' => $print_id])->one(); if (!$print) { throw new Exception('Print not found!'); } $pathPrints = $print->getSavePath() . $print->image; $pathShirt = $this->getSavePath() . $this->image; $image = Image::watermark($pathShirt, $pathPrints); $imageSize = $image->getSize(); $imageData = base64_encode($image->get('png')); $imageHTML = "data:89504E470D0A1A0A;base64,{$imageData}"; return $imageHTML; }
/** * @param $id * * @return models\Prints|array|null */ public function loadPrint($id) { $prints = models\Prints::find()->where('id=:id', [':id' => $id])->one(); return $prints; }
/** * Finds the Prints model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return Prints the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Prints::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }