public function index() { $user = Auth::user(); $company = $user->company; $tariffs = Tariff::published()->get(); return view('account.rise.index')->with(compact(['user', 'company', 'tariffs'])); }
public function getTariffForSelect() { $tariffs = []; $tariffs[] = 'Нет тарифа'; $tariffs = Tariff::all()->pluck('name', 'id'); return $tariffs; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tariff::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'abon_pay' => $this->abon_pay, 'connect_pay' => $this->connect_pay, 'tariff_group_id' => $this->tariff_group_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'incoming', $this->incoming])->andFilterWhere(['like', 'type_attributes', $this->type_attributes]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getTariffs() { return $this->hasMany(Tariff::className(), ['tariff_group_id' => 'id']); }
/** * Finds the Tariff model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tariff the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tariff::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \App\Models\Tariff */ private function createTariff() { $tariff = \App\Models\Tariff::create(['name' => 'BestOfTheBest', 'price' => 123, 'duration' => 10]); return $tariff; }
public function postDelete($id) { $tariff = Tariff::findOrFail($id); $tariff->delete(); return redirect()->action('TariffsController@getIndex')->with('flash_message', 'Тариф <strong>"' . $tariff->name . '"</strong> удален'); }
public function postChooseTariff(Request $request, ParentRepository $parentRepository) { $tariff = Tariff::find($request->get('tariff_id')); $parent = $this->getParent(); $parentRepository->chooseTariff($parent, $tariff); }