コード例 #1
0
ファイル: RunScraper.php プロジェクト: wasgeht-berlin/website
 /**
  * @param $info
  * @param $loc Location
  **/
 protected function createEvent($info, $loc)
 {
     // TODO: validate input types
     $event = Event::create(['title' => $info['title'], 'description' => $info['description'], 'hash' => $info['hash'], 'starting_time' => Carbon::parse($info['starting_time']), 'url' => $info['url']]);
     if (isset($info['ending_time'])) {
         $event->ending_time = Carbon::parse($info['ending_time']);
     }
     if (isset($info['notes'])) {
         $event->notes = $info['notes'];
     }
     $event->location()->associate($loc);
     if (isset($info['tags'])) {
         foreach ($info['tags'] as $tagName) {
             try {
                 $tag = Tag::whereName($tagName)->firstOrFail();
                 $event->tags()->save($tag);
             } catch (ModelNotFoundException $e) {
                 $this->raiseIssue("[{$this->name}]: Unknown tag name '{$tagName}'", "The tag '{$tagName}' is not registered.\n\n" . "Full entity info was:\n\n" . var_export($info, true));
                 continue;
             }
         }
     }
     $event->save();
 }