Пример #1
0
 public static function points()
 {
     $out = [];
     $data = Point::all()->toArray();
     foreach ($data as $k => $d) {
         $out[$d['id']] = $d['address'];
     }
     return $out;
 }
Пример #2
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $storyline = Storyline::where('id', $id)->first();
     $points = null;
     if (!empty($storyline)) {
         $points = Point::where('line_id', $storyline->id)->get();
     }
     return view('pages.storyline_show', ['storyline' => $storyline, 'points' => $points]);
 }
Пример #3
0
 public function update($latitude = null, $longitude = null)
 {
     $latitude = empty($_GET['lat']) ? $latitude : $_GET['lat'];
     $longitude = empty($_GET['lng']) ? $longitude : $_GET['lng'];
     if (!empty($latitude) && !empty($longitude)) {
         $newLocation = $this->api->revgeocode($latitude, $longitude);
         $point = new Point();
         $point->setLat($latitude);
         $point->setLng($longitude);
         $this->location->setPoint($point);
         if (!empty($newLocation)) {
             $this->location->setAddress($newLocation);
         }
         if ($this->isSessionEnabled) {
             $this->location->save();
         }
     }
     $success = (bool) $this->location->getPoint();
     $location = $this->location->toJson();
     return compact("success", "location");
 }
Пример #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, Point::$validation_rules);
     $point = new Point();
     $point->name = $request->input('name');
     $point->description = $request->input('description');
     $point->parent_id = $request->input('parent_id');
     $point->line_id = $request->input('line_id');
     $point->type_id = $request->input('type_id');
     $point->user_id = $request->input('user_id');
     // Check if the chosen point type is available
     if (in_array($point->type_id, \Config::get('sf.unique_type_ids'))) {
         $type_check = Point::where('line_id', $point->line_id)->where('type_id', $point->type_id)->first();
         if (!empty($type_check)) {
             Flash::danger(trans('alerts.point.point_already_set'));
             return redirect()->back()->withInput();
         }
     }
     $point->save();
     Flash::success(trans('alerts.point.added'));
     return redirect(action("StorylineController@show", ['id' => $point->line_id]));
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPoints()
 {
     return $this->hasMany(Point::className(), ['team_id' => 'id']);
 }
Пример #6
0
 /**
  * Finds the Point model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Point the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Point::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #7
0
 public function actionUntop($id)
 {
     $model = $this->findModel($id);
     $point = Point::findOne($model->point_id);
     if ($point->user_id == \Yii::$app->user->id) {
         $model->is_top = 0;
     }
     $r = $model->save();
 }