Esempio n. 1
0
 public function storeMap($request)
 {
     $map = new Map();
     //create public hash
     $hash = "";
     do {
         $hash = str_random(4);
     } while (Map::where("hash", "=", $hash)->first() instanceof Map);
     $map->hash = $hash;
     $values = $request->except('_token', '_method', '_section', 'tags');
     $map->fill($values);
     $map->user()->associate(Auth::user());
     $map->save();
     if ($request->has('tags') && is_array($request->tags)) {
         $tagList = Tag::lists('id')->toArray();
         $cleanTags = array_intersect($request->tags, $tagList);
         $map->tags()->sync($cleanTags);
     }
     return $map;
 }