public function actionIndex() { $query = Link::find(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count('id')]); $links = $query->select(['id', 'name', 'url'])->orderBy(['sortid' => SORT_ASC, 'id' => SORT_DESC])->offset($pages->offset)->limit($pages->limit)->asArray()->all(); return $this->render('index', ['links' => $links, 'pages' => $pages]); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { // dd($this->input('id')); $link = Link::find($this->input('id')); $lesson = Lesson::find($link->lesson_id); $product = $lesson->product; $users = $product->owner()->lists('id'); return in_array(Auth::id(), $users); }
/** * Update friend link, new when don't exists. * * @param $inputs */ public function updateFriend($inputs) { if (isset($inputs['id'])) { $friend = Link::find($inputs['id']); } else { $friend = new Link(); } $friend->name = $inputs['name']; $friend->link = $inputs['link']; $friend->save(); }
public function init() { parent::init(); $links = Link::find()->where('visible=1')->orderBy(['position' => SORT_DESC])->limit($this->max)->all(); echo '<h4>友情链接</h4><ul class="list-unstyled">'; foreach ($links as $key => $value) { $link = Html::a(Html::encode($value->name), $value->url); echo Html::tag('li', $link); } echo "</ul>"; }
public function actionEditUserBlock($id) { $userModel = $this->findUserBlock($id); $model = Block::find()->with('links')->where(['id' => $userModel->block_id])->one(); $states = State::find()->all(); $test = Link::find()->where(['id' => 2])->one(); if ($userModel->load(Yii::$app->request->post()) && $userModel->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('app', '{model} SUCCESS_UPDATED', ['model' => $model->title])); } return $this->render('userSettings', ['userModel' => $userModel, 'model' => $model, 'states' => $states, 'test' => $test]); }
public function search($params) { $query = Link::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'id'); $this->addCondition($query, 'name', true); $this->addCondition($query, 'url', true); $this->addCondition($query, 'logo', true); $this->addCondition($query, 'target'); $this->addCondition($query, 'type'); $this->addCondition($query, 'position'); $this->addCondition($query, 'visible'); return $dataProvider; }
public function actionAjaxaddlinkt($id) { $count = Link::find()->where(['admin_id' => Yii::$app->user->id])->andWhere(['link_type' => 1])->andWhere(['link_id' => $id])->count(); if ($count == 0) { $link = new Link(); $link->link_type = 1; $link->link_id = $id; $link->admin_id = Yii::$app->user->id; $link->time = time(); if ($link->save()) { echo 'турнир добавлен'; } else { echo 'не сохранилось...'; } } else { echo 'уже был добавлен...'; } }
<?php use app\models\User; use app\models\T; use app\models\Link; use yii\helpers\Html; //////////////////// USER ////////////////////// $count_links = 0; if (!Yii::$app->user->isGuest) { $my_t = T::find()->where(['admin_id' => Yii::$app->user->id])->count(); $my_link = Link::find()->where(['admin_id' => Yii::$app->user->id])->count(); $count_links = $my_link + $my_t; } ?> <style> .header-table-small td{ border: 2px solid <?php echo Yii::$app->params['color']['table_bg_dark']; ?> ; margin: 0; padding: 3px 15px; background-color: <?php echo Yii::$app->params['color']['table_bg_dark']; ?> ; color: #ffffff; font-weight: bold; font-size: 16px; }
public function getInfoLink() { return Link::find()->where(['block_id' => $this->id])->orderBy('order')->all(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(ModifyLinkRequest $request) { /** @var Link $link */ $link = Link::find($request->input('id')); if (empty($link)) { Flash::error('Link not found'); return redirect(route('admin.links.index')); } $link->delete(); Flash::message('Link deleted successfully.'); return redirect(route('lessons.edit', [$link->lesson_id]))->with('active_tab', 'links'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $link = Link::find($id); if ($link->delete()) { return response()->json(array('success' => TRUE)); } }
/** * Remove the specified Link from storage. * * @param int $id * * @return Response */ public function destroy($id) { /** @var Link $link */ $link = Link::find($id); if (empty($link)) { Flash::error('Link not found'); return redirect(route('admin.links.index')); } $link->delete(); Flash::message('Link deleted successfully.'); return redirect(route('admin.links.index')); }
public function remove($link_id) { $link = Link::find($link_id); $this->guardAgainstUnauthorizedUsers($link); $link->delete(); }