/** * Execute the console command. * * @return mixed */ public function handle() { // Get every user. $users = User::getUsers(); // Get the message. foreach ($users as $user) { $message = Message::getMessage($user); $client = new \GuzzleHttp\Client(['base_uri' => 'http://localhost:3001']); // Send a request to the node server to post the message. $client->request('POST', '/post', ['json' => ['user' => $user, 'message' => $message]]); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, Request $request) { $message = Message::findOrFail($id); $message->delete(); $request->session()->flash('status', 'Message has been deleted!'); return redirect()->route('messages.index'); }
/** * Display a listing of the resource. * * @return Response */ public function search($term) { // @TODO: this will literally fail if nothing matches, deal with that. $message = Message::where('tags', '=', $term)->first(); return response()->json(['message' => $message->message]); }