public function numberUnreadMessages() { $count = 0; foreach (\App\Message::all() as $message) { if ($message->to == \Auth::User()->id && $message->read == 0) { $count++; } } return $count; }
/** * To handle all the mesaging functionality * * @param int $id * @return Response */ public function getMessage(Request $request) { $userId = Auth::user()->email; $messageReceipaient = MessageReceipient::where('receipient_ID', $userId)->get(); $metaIds = array(); //storing all the message recepiaent foreach ($messageReceipaient as $key => $value) { $metaIds[] = $value['meta_Id']; } //fetching all the message to display $messageReceipaientResult = Message::all(); return $messageReceipaientResult; }
public function onMessage(ConnectionInterface $from, $msg) { $numRecv = count($this->clients) - 1; echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n", $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's'); $data = json_decode($msg); if ($data->status == 'ping') { $data->status == 'pong'; $from->send(json_encode($data)); } if ($data->status == 'open') { $current_user = \App\ChatOnlineUser::where('username', '=', $data->username)->first(); print_r(empty((array) $current_user)); if (!empty($current_user)) { \App\ChatOnlineUser::where('username', '=', $data->username)->delete(); } $chat_user_data = array('username' => $data->username, 'name' => $data->name, 'connection_resource_id' => $from->resourceId); $online_users = \App\ChatOnlineUser::all(); $data->online_users = $online_users->toArray(); \App\ChatOnlineUser::create($chat_user_data); $messages = \App\Message::all(); $data->content = $messages->toArray(); foreach ($this->clients as $client) { //if ($from !== $client) { $client->send(json_encode($data)); //} } } if ($data->status == 'close') { foreach ($this->clients as $client) { if ($from !== $client) { $client->send($msg); } } } if ($data->status == 'message') { $message_data = array('username' => $data->username, 'name' => $data->name, 'message_contents' => $data->content); \App\Message::create($message_data); foreach ($this->clients as $client) { if ($from !== $client) { $client->send($msg); } } } }
/** * Display a listing of the resource. * * @return Response */ public function index() { return Message::all()->toJson(); }
/** * Display Project Discussion page * * @return \Illuminate\View\View */ public function discussion() { $messages = Message::all(); return view('projects.discussion', compact('messages')); }
public function index() { $data['chats'] = Message::all(); return view('index', $data); }
# ------------------ bookmark stuff ------------------------ post('api/bookmark', function () { Auth::user()->bookmark = Request::get('bookmark'); Auth::user()->save(); }); get('api/bookmark', function () { return Auth::user()->bookmark; }); # ------------------ guestbook stuff ------------------------ use App\Message; get('guestbook', function () { return view('guestbook/guestbook'); }); // API get('api/messages', function () { return App\Message::all(); }); post('api/messages', function () { return App\Message::create(Request::all()); }); # ------------------ Password reset stuff ------------------------ // Password reset link request routes... Route::get('password/email', 'Auth\\PasswordController@getEmail'); Route::post('password/email', 'Auth\\PasswordController@postEmail'); // Password reset routes... Route::get('password/reset/{token}', 'Auth\\PasswordController@getReset'); Route::post('password/reset', 'Auth\\PasswordController@postReset'); # ------------------admin info stuff (建设中)------------------------ // Route::resource('info','InfoController'); // get('info', function() { // return view('guestbook/guestbook');
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['messages'] = Message::all(); $data['showCreateMessage'] = true; return \View::make('messages.index')->with($data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $message = Message::all(); return view('pages.home')->with('message', $message); }
/** * View all messages * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function all() { $messages = Message::all(); return $messages; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return response()->json(Message::all()); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $messages = Message::all(); return View::make('MessageBoard', ['message_view' => $messages]); }
/** * Get Messages that are not linked to the Layout ID provided. * * @param \Layout ID */ public function getUnlinkedMessages($elementId) { //$unlinkedMessages = Message::all(); //return $unlinkedMessages; //Find all elements related to a Layout $linkedMessages = ElementsController::getMessages($elementId); //Get the messages that are related to id $linkedMessagesId = $linkedMessages->lists('id'); if (count($linkedMessagesId) == 0) { //If there is no related elements, return all available elements. return Message::all(); } else { //If there is related elements, find the ones that are not related return Message::whereNotIn('id', $linkedMessagesId)->get(); } }
public function senderRequest() { $senders = Sender::all(); $receivers = Receiver::all(); $messages = Message::all(); foreach ($senders as $sender) { $pk_sender = $sender->private_key; } foreach ($receivers as $receiver) { $pk_receiver = $receiver->private_key; } foreach ($messages as $message) { $v = $message->text_message; } $str = ""; $len = strlen($v); for ($y = 0; $y < $len; $y++) { $swap = 0; if ($v[$y] == 'A' || $v[$y] == 'a') { $swap = 1; } if ($v[$y] == 'B' || $v[$y] == 'b') { $swap = 2; } if ($v[$y] == 'C' || $v[$y] == 'c') { $swap = 3; } if ($v[$y] == 'D' || $v[$y] == 'd') { $swap = 4; } if ($v[$y] == 'E' || $v[$y] == 'e') { $swap = 5; } if ($v[$y] == 'F' || $v[$y] == 'f') { $swap = 6; } if ($v[$y] == 'G' || $v[$y] == 'g') { $swap = 7; } if ($v[$y] == 'H' || $v[$y] == 'h') { $swap = 8; } if ($v[$y] == 'I' || $v[$y] == 'i') { $swap = 9; } if ($v[$y] == 'J' || $v[$y] == 'j') { $swap = 10; } if ($v[$y] == 'K' || $v[$y] == 'k') { $swap = 11; } if ($v[$y] == 'L' || $v[$y] == 'l') { $swap = 12; } if ($v[$y] == 'M' || $v[$y] == 'm') { $swap = 13; } if ($v[$y] == 'N' || $v[$y] == 'n') { $swap = 14; } if ($v[$y] == 'O' || $v[$y] == 'o') { $swap = 15; } if ($v[$y] == 'P' || $v[$y] == 'p') { $swap = 16; } $m = $swap; $r = $pk_sender; $s = $pk_receiver; $r1 = pow(3, $r) % 17; $s1 = pow(3, $s) % 17; $r2 = pow($s1, $r) % 17; $s2 = pow($r1, $s) % 17; $c = $r2 * $m % 17; if ($c == 1) { $str = $str . "A"; } if ($c == 2) { $str = $str . "B"; } if ($c == 3) { $str = $str . "C"; } if ($c == 4) { $str = $str . "D"; } if ($c == 5) { $str = $str . "E"; } if ($c == 6) { $str = $str . "F"; } if ($c == 7) { $str = $str . "G"; } if ($c == 8) { $str = $str . "H"; } if ($c == 9) { $str = $str . "I"; } if ($c == 10) { $str = $str . "J"; } if ($c == 11) { $str = $str . "K"; } if ($c == 12) { $str = $str . "L"; } if ($c == 13) { $str = $str . "M"; } if ($c == 14) { $str = $str . "N"; } if ($c == 15) { $str = $str . "O"; } if ($c == 16) { $str = $str . "P"; } } foreach ($senders as $sender) { $sender->encrypted_text = $str; $sender->save(); } return redirect('/sender'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $messages = Message::all(); return view('admin.inbox', compact('messages')); }
public function index() { $messages = Message::all()->all(); return view('pages.contact.index', compact('messages')); }
<?php use App\Message; get('guestbook', function () { return view('guestbook'); }); // API get('api/messages', function () { return Message::all(); }); post('api/messages', function () { return Message::create(Request::all()); });
public function messages() { return view('admin.main')->with('messages', Message::all()); }
public function messagesClean() { return Message::all()->each(function ($message) { $message->forceDelete(); }); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $messages = Message::all(); return view('contact.index', compact($messages)); }
<?php use App\User; use App\Message; /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { Blade::setContentTags('[%', '%]'); return view('welcome'); }); get('/users', function () { return response()->json(User::all()); }); get('/user/tickets', function () { return response()->json([1 => ['name' => '合同1'], 2 => ['name' => '合同2']]); }); get('/messages', function () { return response()->json(Message::all()); }); post('post/store', 'App\\Http\\Controllers\\PostController@store');