Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
 /**
  * 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');
 }