/**
  * Store a newly created resource in storage.
  *
  * @NOTE That Tags should be a comma seperated list of tag_id's.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         $validator = \Validator::make($request->all(), ['name' => 'required|min:3', 'description' => 'required|min:3', 'latitude' => 'required|min:3', 'longitude' => 'required|min:3', 'tags' => 'required', 'country' => 'required', 'files' => 'required']);
         if ($validator->fails()) {
             return $this->respondWithError($validator->errors());
         }
         $point = new Point();
         $point->name = $request->get('name');
         $point->description = $request->get('description');
         $point->longitude = $request->get('longitude');
         $point->latitude = $request->get('latitude');
         $point->country = $request->get('country');
         $point->created_by = Auth::user()->id;
         $point->updated_by = Auth::user()->id;
         if (!$point->save()) {
             return $this->respondWithError();
         }
         /* @param tags !NOTE! Tags should be a comma seperated list of tag id's */
         $tags = explode(',', $request->get('tags'));
         foreach ($tags as $t) {
             $tag = new PointTag();
             $tag->point_id = $point->id;
             $tag->created_by = Auth::user()->id;
             $tag->tags_id = $t;
             if (!$tag->save()) {
                 return $this->respondWithError('Could not add tag (' . $t . ')');
             }
         }
         $this->addFiles($request->get('files'));
         return Fractal::item($point, new PointTransformer())->responseJson(200);
     } catch (Exception $e) {
         return $this->respondInternalError();
     }
 }