Ejemplo n.º 1
0
 public static function send($to, $from, $title, $message_body)
 {
     $message = new \App\Message();
     $message->to = $to;
     $message->from = $from;
     $message->title = $title;
     $message->message = $message_body;
     $message->read = false;
     $message->save();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['message' => 'required']);
     $users = $request["users"];
     $created_by = $request["created_by"];
     $msg = $request["message"];
     $conv = new \App\Conversation();
     $conv->created_by = $created_by;
     $conv->save();
     $message = new \App\Message();
     $message->user_id = $created_by;
     $message->conversation_id = $conv->id;
     $message->message = $msg;
     $message->save();
     $conv->users()->sync($users);
     return $conv;
 }