/** * Display a listing of the resource. * * @return Response */ public function index() { //returns an array of objects $chatmessages = Chat::all(); $auth = new Auth(); // echo "<pre>"; var_dump($auth::user()->name);die('x'); //Adds user's name to obj foreach ($chatmessages as $key => $result) { $chatmessages[$key]->name = $auth::user()->name; } return view('chat.index', compact('chatmessages')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { return Chat::all(); }