public function createChatRoom() { $valid = Validator::make(Input::all(), array('name' => 'required|max:50|unique:chat_rooms')); if ($valid->fails()) { return Redirect::route('home')->withErrors($valid)->withInput(); } $chatroom_name = Input::get('name'); $chat_room_id = ChatRoom::insertGetId(array('name' => $chatroom_name, 'file' => str_random(40))); Session::put('message', 'New chatroom has been added successfully'); return $this->registerChatroom($chat_room_id); }