/**
  * @param array $talk
  * @return Talk
  */
 private function createTalk($talk)
 {
     $data = ['is_talk' => (int) $talk['is_talk'], 'track' => (int) $talk['track'] > 0 ? (int) $talk['track'] : null, 'title' => $talk['title'], 'starts_at' => $talk['starts_at'], 'ends_at' => $talk['ends_at']];
     if (isset($talk['author']) && ($speaker = Speaker::whereName($talk['author'])->first())) {
         return $speaker->talks()->create($data);
     }
     return Talk::create($data);
 }
 public function submitTalk(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required', 'name' => 'required', 'email' => 'required|email', 'event' => 'required|numeric']);
     $talk = new Talk();
     $talk->title = $request->input('title');
     $talk->description = $request->input('description');
     $talk->extra = $request->input('extra');
     $talk->format = $request->input('format');
     $talk->name = $request->input('name');
     $talk->email = $request->input('email');
     $talk->event_id = $request->input('event');
     $talk->twitter = $request->input('twitter');
     $talk->slack = $request->input('slack');
     $talk->save();
     $admin = User::where('email', '=', env('ADMIN_EMAIL'))->first();
     $subject = '[CCH] Talk submitted: ' . $talk->title;
     Mail::send('emails.talk', ['talk' => $talk], function (Message $m) use($talk, $admin, $subject) {
         $m->to($admin->email);
         $m->replyTo($talk->email);
         $m->subject($subject);
     });
     return redirect()->route('submitTalkSuccess');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $talks = Talk::all();
     // for testing purposes
     //$talks = Talk::orderBy('starts_at')->skip(11)->take(1)->get();
     if (!$talks->count()) {
         return false;
     }
     $remindersPushed = [];
     foreach ($talks as $talk) {
         $this->pushTalk($talk, !in_array($talk->starts_at, $remindersPushed));
         $remindersPushed[] = (string) $talk->starts_at;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $talk = Talk::findOrFail($id);
     return view('talk.details')->with(['talk' => $talk]);
 }