Skip to content

Commit

Permalink
user fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealJAG committed Jun 4, 2017
1 parent 3887cad commit 61a5bd8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
16 changes: 9 additions & 7 deletions app/Http/Controllers/UserController.php
Expand Up @@ -15,8 +15,7 @@ class UserController extends Controller
* @param int $id
* @return Response
*/
public function index($id)
{
public function index($id) {
$user = User::findOrFail($id);

if (!$user)
Expand All @@ -27,15 +26,13 @@ public function index($id)
return view('user.index')->with('questions',$questions)->with('user',$user)->with('answers',$answers)->with('page_title', $user->name . '');
}

public function questions($id)
{
public function questions($id) {
$user = User::findOrFail($id);
$questions = Question::where('user_id', '=', $id)->orderBy('id','DESC')->paginate(10);
return view('user.questions')->with('questions',$questions)->with('user',$user)->with('page_title', $user->name . ' Questions');
}

public function answers($id)
{
public function answers($id) {
$user = User::findOrFail($id);
$answers = Answer::where('user_id', '=', $id)->orderBy('id','DESC')->paginate(10);
return view('user.answers')->with('user',$user)->with('answers',$answers)->with('page_title', $user->name . 'Answers');
Expand All @@ -48,11 +45,16 @@ public function participation($id) {
}

public function notifications($id) {
$user = User::findOrFail($id);

if (!isset(Auth::user()->id))
abort(401, "Unauthorized");

if(Auth::user()->id == $id) {
$user = User::findOrFail($id);
return view('user.notifications')->with('user',$user)->with('user',$user)->with('page_title', $user->name . 'Notifications');
} else {
abort(401, "Unauthorized");
}

}
}
3 changes: 3 additions & 0 deletions app/Question.php
Expand Up @@ -186,6 +186,9 @@ public static function insert($user_id, $tags, $question_text) {
}
}
}

// Give a vote to the new question by author
Vote::vote($user_id, $question->id, 1, 'question_id');
return $question;
}

Expand Down
1 change: 1 addition & 0 deletions resources/views/containers/answer.blade.php
Expand Up @@ -28,4 +28,5 @@

</div>
</div>
<br><!-- todo remove br and use css for exact positioning -->
<!-- End Answer Container-->
12 changes: 2 additions & 10 deletions tests/Feature/QuestionTest.php
Expand Up @@ -17,10 +17,6 @@
class QuestionTest extends TestCase
{

public function testStart() {
echo 'Start';
}

public function testQuestion()
{
// Test inserting a user
Expand All @@ -45,6 +41,7 @@ public function testQuestion()

// This test should also produce records in the notifications table
// See notifications table...
print "Done Testing testQuestion";
}

// Test a user creation and all user pages.
Expand All @@ -60,13 +57,8 @@ public function testUser() {

$response = $this->call('GET', '/user/'.$this->user->id.'/answers');
$this->assertEquals(200, $response->status());
print "Done Testing testUser";
}

public function testStope() {
echo 'DONE';
}




}

0 comments on commit 61a5bd8

Please sign in to comment.