function createThreads() { $thread = Thread::create(['subject' => "Check"]); // Message Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => "Hellooooo."]); // Sender Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]); // Recipients }
/** * Stores a new message thread * * @return mixed */ public function store() { $input = Input::all(); $thread = Thread::create(['subject' => $input['subject']]); // Message Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => $input['message']]); // Sender Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]); // Recipients if (Input::has('recipients')) { $thread->addParticipants($input['recipients']); } return Redirect::to('messages'); }