Passed
Branch master (828252)
by Omar El
04:00
created
app/Exceptions/Handler.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Illuminate\Database\Eloquent\ModelNotFoundException;
9 9
 use Symfony\Component\HttpKernel\Exception\HttpException;
10 10
 use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
11
-
12 11
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
13 12
 use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
14 13
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,15 +48,15 @@
 block discarded – undo
48 48
      */
49 49
     public function render($request, Exception $e)
50 50
     {
51
-        if(env('APP_DEBUG')){
51
+        if (env('APP_DEBUG')) {
52 52
             return parent::render($request, $e);
53 53
         }
54 54
 
55
-        if($e instanceof NotFoundHttpException){
55
+        if ($e instanceof NotFoundHttpException) {
56 56
             return response()->json(['message' => 'Bad Request', 'code' => 400], 400);
57 57
         }
58 58
 
59
-        if($e instanceof MethodNotAllowedHttpException){
59
+        if ($e instanceof MethodNotAllowedHttpException) {
60 60
             return response()->json(['message' => 'Not Found', 'code' => 404], 404);
61 61
         }
62 62
 
Please login to merge, or discard this patch.
app/Http/Controllers/Controller.php 3 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,6 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * Return a JSON response for error.
23 23
      *
24
-     * @param  array  $data
25 24
      * @param  string $code
26 25
      * @return \Illuminate\Http\JsonResponse
27 26
      */
@@ -33,7 +32,7 @@  discard block
 block discarded – undo
33 32
      * Check if the user is authorized to perform a given action on a resource.
34 33
      *
35 34
      * @param  \Illuminate\Http\Request  $request
36
-     * @param  array $resource
35
+     * @param  string $resource
37 36
      * @param  mixed|array $arguments
38 37
      * @return boolean
39 38
      * @see    https://lumen.laravel.com/docs/authorization 
@@ -67,9 +66,6 @@  discard block
 block discarded – undo
67 66
      * Get current authorized user id.
68 67
      * This method should be called only after validating the access token using OAuthMiddleware Middleware.
69 68
      *
70
-     * @param  \Illuminate\Http\Request  $request
71
-     * @param  array $resource
72
-     * @param  array $data
73 69
      * @return boolean
74 70
      * 
75 71
      * @throws LucaDegasperi\OAuth2Server\Exceptions\NoActiveAccessTokenException
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
      * @param  string $code
15 15
      * @return \Illuminate\Http\JsonResponse
16 16
      */
17
-	public function success($data, $code){
18
-		return response()->json(['data' => $data], $code);
19
-	}
17
+    public function success($data, $code){
18
+        return response()->json(['data' => $data], $code);
19
+    }
20 20
 
21 21
     /**
22 22
      * Return a JSON response for error.
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      * @param  string $code
26 26
      * @return \Illuminate\Http\JsonResponse
27 27
      */
28
-	public function error($message, $code){
29
-		return response()->json(['message' => $message], $code);
30
-	}
28
+    public function error($message, $code){
29
+        return response()->json(['message' => $message], $code);
30
+    }
31 31
 
32 32
     /**
33 33
      * Check if the user is authorized to perform a given action on a resource.
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
      */
41 41
     protected function authorizeUser(Request $request, $resource, $arguments = []){
42 42
     	
43
-    	$user 	 = User::find($this->getUserId());
44
-    	$action	 = $this->getAction($request); 
43
+        $user 	 = User::find($this->getUserId());
44
+        $action	 = $this->getAction($request); 
45 45
 
46 46
         // The ability string must match the string defined in App\Providers\AuthServiceProvider\ability()
47 47
         $ability = "{$action}-{$resource}";
48 48
 
49
-    	// return $this->authorizeForUser($user, "{$action}-{$resource}", $data);
50
-    	return Gate::forUser($user)->allows($ability, $arguments);
49
+        // return $this->authorizeForUser($user, "{$action}-{$resource}", $data);
50
+        return Gate::forUser($user)->allows($ability, $arguments);
51 51
     }
52 52
 
53 53
     /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @throws LucaDegasperi\OAuth2Server\Exceptions\NoActiveAccessTokenException
76 76
      */
77 77
     protected function getUserId(){
78
-    	return \LucaDegasperi\OAuth2Server\Facades\Authorizer::getResourceOwnerId();
78
+        return \LucaDegasperi\OAuth2Server\Facades\Authorizer::getResourceOwnerId();
79 79
     }
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use App\User;
6 6
 use Gate;
7 7
 
8
-class Controller extends BaseController{
8
+class Controller extends BaseController {
9 9
 
10 10
     /**
11 11
      * Return a JSON response for success.
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      * @param  string $code
15 15
      * @return \Illuminate\Http\JsonResponse
16 16
      */
17
-	public function success($data, $code){
17
+	public function success($data, $code) {
18 18
 		return response()->json(['data' => $data], $code);
19 19
 	}
20 20
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param  string $code
26 26
      * @return \Illuminate\Http\JsonResponse
27 27
      */
28
-	public function error($message, $code){
28
+	public function error($message, $code) {
29 29
 		return response()->json(['message' => $message], $code);
30 30
 	}
31 31
 
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
      * @return boolean
39 39
      * @see    https://lumen.laravel.com/docs/authorization 
40 40
      */
41
-    protected function authorizeUser(Request $request, $resource, $arguments = []){
41
+    protected function authorizeUser(Request $request, $resource, $arguments = []) {
42 42
     	
43
-    	$user 	 = User::find($this->getUserId());
44
-    	$action	 = $this->getAction($request); 
43
+    	$user = User::find($this->getUserId());
44
+    	$action = $this->getAction($request); 
45 45
 
46 46
         // The ability string must match the string defined in App\Providers\AuthServiceProvider\ability()
47 47
         $ability = "{$action}-{$resource}";
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param  \Illuminate\Http\Request  $request
60 60
      * @return bool
61 61
      */
62
-    public function isAuthorized(Request $request){
62
+    public function isAuthorized(Request $request) {
63 63
         return false;
64 64
     }
65 65
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * 
75 75
      * @throws LucaDegasperi\OAuth2Server\Exceptions\NoActiveAccessTokenException
76 76
      */
77
-    protected function getUserId(){
77
+    protected function getUserId() {
78 78
     	return \LucaDegasperi\OAuth2Server\Facades\Authorizer::getResourceOwnerId();
79 79
     }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param  \Illuminate\Http\Request  $request
85 85
      * @return string
86 86
      */
87
-    protected function getAction(Request $request){
87
+    protected function getAction(Request $request) {
88 88
         return explode('@', $request->route()[1]["uses"], 2)[1];
89 89
     }
90 90
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * @param  \Illuminate\Http\Request  $request
95 95
      * @return array
96 96
      */
97
-    protected function getArgs(Request $request){
97
+    protected function getArgs(Request $request) {
98 98
         return $request->route()[2];
99 99
     }
100 100
 }
Please login to merge, or discard this patch.
app/Http/Controllers/PostCommentController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use App\Post;
4 4
 use App\Comment;
5
-
6 5
 use Illuminate\Http\Request;
7 6
 
8 7
 class PostCommentController extends Controller{
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -7,95 +7,95 @@
 block discarded – undo
7 7
 
8 8
 class PostCommentController extends Controller{
9 9
 
10
-	public function __construct(){
10
+    public function __construct(){
11 11
 		
12
-		$this->middleware('oauth', ['except' => ['index', 'show']]);
13
-		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
14
-	}
12
+        $this->middleware('oauth', ['except' => ['index', 'show']]);
13
+        $this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
14
+    }
15 15
 
16
-	public function index($post_id){
16
+    public function index($post_id){
17 17
 
18
-		$post = Post::find($post_id);
18
+        $post = Post::find($post_id);
19 19
 
20
-		if(!$post){
21
-			return $this->error("The post with {$post_id} doesn't exist", 404);
22
-		}
20
+        if(!$post){
21
+            return $this->error("The post with {$post_id} doesn't exist", 404);
22
+        }
23 23
 
24
-		$comments = $post->comments;
25
-		return $this->success($comments, 200);
26
-	}
24
+        $comments = $post->comments;
25
+        return $this->success($comments, 200);
26
+    }
27 27
 
28
-	public function store(Request $request, $post_id){
28
+    public function store(Request $request, $post_id){
29 29
 		
30
-		$post = Post::find($post_id);
30
+        $post = Post::find($post_id);
31 31
 
32
-		if(!$post){
33
-			return $this->error("The post with {$post_id} doesn't exist", 404);
34
-		}
32
+        if(!$post){
33
+            return $this->error("The post with {$post_id} doesn't exist", 404);
34
+        }
35 35
 
36
-		$this->validateRequest($request);
36
+        $this->validateRequest($request);
37 37
 
38
-		$comment = Comment::create([
39
-				'content' => $request->get('content'),
40
-				'user_id'=> $this->getUserId(),
41
-				'post_id'=> $post_id
42
-			]);
38
+        $comment = Comment::create([
39
+                'content' => $request->get('content'),
40
+                'user_id'=> $this->getUserId(),
41
+                'post_id'=> $post_id
42
+            ]);
43 43
 
44
-		return $this->success("The comment with id {$comment->id} has been created and assigned to the post with id {$post_id}", 201);
45
-	}
44
+        return $this->success("The comment with id {$comment->id} has been created and assigned to the post with id {$post_id}", 201);
45
+    }
46 46
 
47
-	public function update(Request $request, $post_id, $comment_id){
47
+    public function update(Request $request, $post_id, $comment_id){
48 48
 
49
-		$comment 	= Comment::find($comment_id);
50
-		$post 		= Post::find($post_id);
49
+        $comment 	= Comment::find($comment_id);
50
+        $post 		= Post::find($post_id);
51 51
 
52
-		if(!$comment || !$post){
53
-			return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
54
-		}
52
+        if(!$comment || !$post){
53
+            return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
54
+        }
55 55
 
56
-		$this->validateRequest($request);
56
+        $this->validateRequest($request);
57 57
 
58
-		$comment->content 		= $request->get('content');
59
-		$comment->user_id 		= $this->getUserId();
60
-		$comment->post_id 		= $post_id;
58
+        $comment->content 		= $request->get('content');
59
+        $comment->user_id 		= $this->getUserId();
60
+        $comment->post_id 		= $post_id;
61 61
 
62
-		$comment->save();
62
+        $comment->save();
63 63
 
64
-		return $this->success("The comment with with id {$comment->id} has been updated", 200);
65
-	}
64
+        return $this->success("The comment with with id {$comment->id} has been updated", 200);
65
+    }
66 66
 
67
-	public function destroy($post_id, $comment_id){
67
+    public function destroy($post_id, $comment_id){
68 68
 		
69
-		$comment 	= Comment::find($comment_id);
70
-		$post 		= Post::find($post_id);
69
+        $comment 	= Comment::find($comment_id);
70
+        $post 		= Post::find($post_id);
71 71
 
72
-		if(!$comment || !$post){
73
-			return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
74
-		}
72
+        if(!$comment || !$post){
73
+            return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
74
+        }
75 75
 
76
-		if(!$post->comments()->find($comment_id)){
77
-			return $this->error("The comment with id {$comment_id} isn't assigned to the post with id {$post_id}", 409);
78
-		}
76
+        if(!$post->comments()->find($comment_id)){
77
+            return $this->error("The comment with id {$comment_id} isn't assigned to the post with id {$post_id}", 409);
78
+        }
79 79
 
80
-		$comment->delete();
80
+        $comment->delete();
81 81
 
82
-		return $this->success("The comment with id {$comment_id} has been removed of the post {$post_id}", 200);
83
-	}
82
+        return $this->success("The comment with id {$comment_id} has been removed of the post {$post_id}", 200);
83
+    }
84 84
 
85
-	public function validateRequest(Request $request){
85
+    public function validateRequest(Request $request){
86 86
 
87
-		$rules = [
88
-			'content' => 'required'
89
-		];
87
+        $rules = [
88
+            'content' => 'required'
89
+        ];
90 90
 
91
-		$this->validate($request, $rules);
92
-	}
91
+        $this->validate($request, $rules);
92
+    }
93 93
 
94
-	public function isAuthorized(Request $request){
94
+    public function isAuthorized(Request $request){
95 95
 
96
-		$resource  = "comments";
97
-		$comment   = Comment::find($this->getArgs($request)["comment_id"]);
96
+        $resource  = "comments";
97
+        $comment   = Comment::find($this->getArgs($request)["comment_id"]);
98 98
 
99
-		return $this->authorizeUser($request, $resource, $comment);
100
-	}
99
+        return $this->authorizeUser($request, $resource, $comment);
100
+    }
101 101
 }
102 102
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@  discard block
 block discarded – undo
5 5
 
6 6
 use Illuminate\Http\Request;
7 7
 
8
-class PostCommentController extends Controller{
8
+class PostCommentController extends Controller {
9 9
 
10
-	public function __construct(){
10
+	public function __construct() {
11 11
 		
12 12
 		$this->middleware('oauth', ['except' => ['index', 'show']]);
13 13
 		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
14 14
 	}
15 15
 
16
-	public function index($post_id){
16
+	public function index($post_id) {
17 17
 
18 18
 		$post = Post::find($post_id);
19 19
 
20
-		if(!$post){
20
+		if (!$post) {
21 21
 			return $this->error("The post with {$post_id} doesn't exist", 404);
22 22
 		}
23 23
 
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 		return $this->success($comments, 200);
26 26
 	}
27 27
 
28
-	public function store(Request $request, $post_id){
28
+	public function store(Request $request, $post_id) {
29 29
 		
30 30
 		$post = Post::find($post_id);
31 31
 
32
-		if(!$post){
32
+		if (!$post) {
33 33
 			return $this->error("The post with {$post_id} doesn't exist", 404);
34 34
 		}
35 35
 
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 		return $this->success("The comment with id {$comment->id} has been created and assigned to the post with id {$post_id}", 201);
45 45
 	}
46 46
 
47
-	public function update(Request $request, $post_id, $comment_id){
47
+	public function update(Request $request, $post_id, $comment_id) {
48 48
 
49
-		$comment 	= Comment::find($comment_id);
50
-		$post 		= Post::find($post_id);
49
+		$comment = Comment::find($comment_id);
50
+		$post = Post::find($post_id);
51 51
 
52
-		if(!$comment || !$post){
52
+		if (!$comment || !$post) {
53 53
 			return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
54 54
 		}
55 55
 
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
 		return $this->success("The comment with with id {$comment->id} has been updated", 200);
65 65
 	}
66 66
 
67
-	public function destroy($post_id, $comment_id){
67
+	public function destroy($post_id, $comment_id) {
68 68
 		
69
-		$comment 	= Comment::find($comment_id);
70
-		$post 		= Post::find($post_id);
69
+		$comment = Comment::find($comment_id);
70
+		$post = Post::find($post_id);
71 71
 
72
-		if(!$comment || !$post){
72
+		if (!$comment || !$post) {
73 73
 			return $this->error("The comment with {$comment_id} or the post with id {$post_id} doesn't exist", 404);
74 74
 		}
75 75
 
76
-		if(!$post->comments()->find($comment_id)){
76
+		if (!$post->comments()->find($comment_id)) {
77 77
 			return $this->error("The comment with id {$comment_id} isn't assigned to the post with id {$post_id}", 409);
78 78
 		}
79 79
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		return $this->success("The comment with id {$comment_id} has been removed of the post {$post_id}", 200);
83 83
 	}
84 84
 
85
-	public function validateRequest(Request $request){
85
+	public function validateRequest(Request $request) {
86 86
 
87 87
 		$rules = [
88 88
 			'content' => 'required'
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		$this->validate($request, $rules);
92 92
 	}
93 93
 
94
-	public function isAuthorized(Request $request){
94
+	public function isAuthorized(Request $request) {
95 95
 
96 96
 		$resource  = "comments";
97 97
 		$comment   = Comment::find($this->getArgs($request)["comment_id"]);
Please login to merge, or discard this patch.
app/Http/Controllers/PostController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace App\Http\Controllers;
2 2
 
3 3
 use App\Post;
4
-
5 4
 use Illuminate\Http\Request;
6 5
 
7 6
 class PostController extends Controller{
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -6,92 +6,92 @@
 block discarded – undo
6 6
 
7 7
 class PostController extends Controller{
8 8
 
9
-	public function __construct(){
9
+    public function __construct(){
10 10
 
11
-		$this->middleware('oauth', ['except' => ['index', 'show']]);
12
-		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
13
-	}
11
+        $this->middleware('oauth', ['except' => ['index', 'show']]);
12
+        $this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
13
+    }
14 14
 
15
-	public function index(){
15
+    public function index(){
16 16
 
17
-		$posts = Post::all();
18
-		return $this->success($posts, 200);
19
-	}
17
+        $posts = Post::all();
18
+        return $this->success($posts, 200);
19
+    }
20 20
 
21
-	public function store(Request $request){
21
+    public function store(Request $request){
22 22
 
23
-		$this->validateRequest($request);
23
+        $this->validateRequest($request);
24 24
 
25
-		$post = Post::create([
26
-					'title' => $request->get('title'),
27
-					'content'=> $request->get('content'),
28
-					'user_id' => $this->getUserId()
29
-				]);
25
+        $post = Post::create([
26
+                    'title' => $request->get('title'),
27
+                    'content'=> $request->get('content'),
28
+                    'user_id' => $this->getUserId()
29
+                ]);
30 30
 
31
-		return $this->success("The post with with id {$post->id} has been created", 201);
32
-	}
31
+        return $this->success("The post with with id {$post->id} has been created", 201);
32
+    }
33 33
 
34
-	public function show($id){
34
+    public function show($id){
35 35
 
36
-		$post = Post::find($id);
36
+        $post = Post::find($id);
37 37
 
38
-		if(!$post){
39
-			return $this->error("The post with {$id} doesn't exist", 404);
40
-		}
38
+        if(!$post){
39
+            return $this->error("The post with {$id} doesn't exist", 404);
40
+        }
41 41
 
42
-		return $this->success($post, 200);
43
-	}
42
+        return $this->success($post, 200);
43
+    }
44 44
 
45
-	public function update(Request $request, $id){
45
+    public function update(Request $request, $id){
46 46
 
47
-		$post = Post::find($id);
47
+        $post = Post::find($id);
48 48
 
49
-		if(!$post){
50
-			return $this->error("The post with {$id} doesn't exist", 404);
51
-		}
49
+        if(!$post){
50
+            return $this->error("The post with {$id} doesn't exist", 404);
51
+        }
52 52
 
53
-		$this->validateRequest($request);
53
+        $this->validateRequest($request);
54 54
 
55
-		$post->title 		= $request->get('title');
56
-		$post->content 		= $request->get('content');
57
-		$post->user_id 		= $this->getUserId();
55
+        $post->title 		= $request->get('title');
56
+        $post->content 		= $request->get('content');
57
+        $post->user_id 		= $this->getUserId();
58 58
 
59
-		$post->save();
59
+        $post->save();
60 60
 
61
-		return $this->success("The post with with id {$post->id} has been updated", 200);
62
-	}
61
+        return $this->success("The post with with id {$post->id} has been updated", 200);
62
+    }
63 63
 
64
-	public function destroy($id){
64
+    public function destroy($id){
65 65
 
66
-		$post = Post::find($id);
66
+        $post = Post::find($id);
67 67
 
68
-		if(!$post){
69
-			return $this->error("The post with {$id} doesn't exist", 404);
70
-		}
68
+        if(!$post){
69
+            return $this->error("The post with {$id} doesn't exist", 404);
70
+        }
71 71
 
72
-		// no need to delete the comments for the current post,
73
-		// since we used on delete cascase on update cascase.
74
-		// $post->comments()->delete();
75
-		$post->delete();
72
+        // no need to delete the comments for the current post,
73
+        // since we used on delete cascase on update cascase.
74
+        // $post->comments()->delete();
75
+        $post->delete();
76 76
 
77
-		return $this->success("The post with with id {$id} has been deleted along with it's comments", 200);
78
-	}
77
+        return $this->success("The post with with id {$id} has been deleted along with it's comments", 200);
78
+    }
79 79
 
80
-	public function validateRequest(Request $request){
80
+    public function validateRequest(Request $request){
81 81
 
82
-		$rules = [
83
-			'title' => 'required', 
84
-			'content' => 'required'
85
-		];
82
+        $rules = [
83
+            'title' => 'required', 
84
+            'content' => 'required'
85
+        ];
86 86
 
87
-		$this->validate($request, $rules);
88
-	}
87
+        $this->validate($request, $rules);
88
+    }
89 89
 
90
-	public function isAuthorized(Request $request){
90
+    public function isAuthorized(Request $request){
91 91
 
92
-		$resource = "posts";
93
-		$post     = Post::find($this->getArgs($request)["post_id"]);
92
+        $resource = "posts";
93
+        $post     = Post::find($this->getArgs($request)["post_id"]);
94 94
 
95
-		return $this->authorizeUser($request, $resource, $post);
96
-	}
95
+        return $this->authorizeUser($request, $resource, $post);
96
+    }
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Illuminate\Http\Request;
6 6
 
7
-class PostController extends Controller{
7
+class PostController extends Controller {
8 8
 
9
-	public function __construct(){
9
+	public function __construct() {
10 10
 
11 11
 		$this->middleware('oauth', ['except' => ['index', 'show']]);
12 12
 		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show', 'store']]);
13 13
 	}
14 14
 
15
-	public function index(){
15
+	public function index() {
16 16
 
17 17
 		$posts = Post::all();
18 18
 		return $this->success($posts, 200);
19 19
 	}
20 20
 
21
-	public function store(Request $request){
21
+	public function store(Request $request) {
22 22
 
23 23
 		$this->validateRequest($request);
24 24
 
@@ -31,28 +31,28 @@  discard block
 block discarded – undo
31 31
 		return $this->success("The post with with id {$post->id} has been created", 201);
32 32
 	}
33 33
 
34
-	public function show($id){
34
+	public function show($id) {
35 35
 
36 36
 		$post = Post::find($id);
37 37
 
38
-		if(!$post){
38
+		if (!$post) {
39 39
 			return $this->error("The post with {$id} doesn't exist", 404);
40 40
 		}
41 41
 
42 42
 		return $this->success($post, 200);
43 43
 	}
44 44
 
45
-	public function update(Request $request, $id){
45
+	public function update(Request $request, $id) {
46 46
 
47 47
 		$post = Post::find($id);
48 48
 
49
-		if(!$post){
49
+		if (!$post) {
50 50
 			return $this->error("The post with {$id} doesn't exist", 404);
51 51
 		}
52 52
 
53 53
 		$this->validateRequest($request);
54 54
 
55
-		$post->title 		= $request->get('title');
55
+		$post->title = $request->get('title');
56 56
 		$post->content 		= $request->get('content');
57 57
 		$post->user_id 		= $this->getUserId();
58 58
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		return $this->success("The post with with id {$post->id} has been updated", 200);
62 62
 	}
63 63
 
64
-	public function destroy($id){
64
+	public function destroy($id) {
65 65
 
66 66
 		$post = Post::find($id);
67 67
 
68
-		if(!$post){
68
+		if (!$post) {
69 69
 			return $this->error("The post with {$id} doesn't exist", 404);
70 70
 		}
71 71
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		return $this->success("The post with with id {$id} has been deleted along with it's comments", 200);
78 78
 	}
79 79
 
80
-	public function validateRequest(Request $request){
80
+	public function validateRequest(Request $request) {
81 81
 
82 82
 		$rules = [
83 83
 			'title' => 'required', 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$this->validate($request, $rules);
88 88
 	}
89 89
 
90
-	public function isAuthorized(Request $request){
90
+	public function isAuthorized(Request $request) {
91 91
 
92 92
 		$resource = "posts";
93 93
 		$post     = Post::find($this->getArgs($request)["post_id"]);
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace App\Http\Controllers;
2 2
 
3 3
 use App\User;
4
-
5 4
 use Illuminate\Http\Request;
6 5
 use Illuminate\Support\Facades\Hash;
7 6
 
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,87 +7,87 @@
 block discarded – undo
7 7
 
8 8
 class UserController extends Controller{
9 9
 
10
-	public function __construct(){
10
+    public function __construct(){
11 11
 
12
-		$this->middleware('oauth', ['except' => ['index', 'show']]);
13
-		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show']]);
14
-	}
12
+        $this->middleware('oauth', ['except' => ['index', 'show']]);
13
+        $this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show']]);
14
+    }
15 15
 
16
-	public function index(){
16
+    public function index(){
17 17
 
18
-		$users = User::all();
19
-		return $this->success($users, 200);
20
-	}
18
+        $users = User::all();
19
+        return $this->success($users, 200);
20
+    }
21 21
 
22
-	public function store(Request $request){
22
+    public function store(Request $request){
23 23
 
24
-		$this->validateRequest($request);
24
+        $this->validateRequest($request);
25 25
 
26
-		$user = User::create([
27
-					'email' => $request->get('email'),
28
-					'password'=> Hash::make($request->get('password'))
29
-				]);
26
+        $user = User::create([
27
+                    'email' => $request->get('email'),
28
+                    'password'=> Hash::make($request->get('password'))
29
+                ]);
30 30
 
31
-		return $this->success("The user with with id {$user->id} has been created", 201);
32
-	}
31
+        return $this->success("The user with with id {$user->id} has been created", 201);
32
+    }
33 33
 
34
-	public function show($id){
34
+    public function show($id){
35 35
 
36
-		$user = User::find($id);
36
+        $user = User::find($id);
37 37
 
38
-		if(!$user){
39
-			return $this->error("The user with {$id} doesn't exist", 404);
40
-		}
38
+        if(!$user){
39
+            return $this->error("The user with {$id} doesn't exist", 404);
40
+        }
41 41
 
42
-		return $this->success($user, 200);
43
-	}
42
+        return $this->success($user, 200);
43
+    }
44 44
 
45
-	public function update(Request $request, $id){
45
+    public function update(Request $request, $id){
46 46
 
47
-		$user = User::find($id);
47
+        $user = User::find($id);
48 48
 
49
-		if(!$user){
50
-			return $this->error("The user with {$id} doesn't exist", 404);
51
-		}
49
+        if(!$user){
50
+            return $this->error("The user with {$id} doesn't exist", 404);
51
+        }
52 52
 
53
-		$this->validateRequest($request);
53
+        $this->validateRequest($request);
54 54
 
55
-		$user->email 		= $request->get('email');
56
-		$user->password 	= Hash::make($request->get('password'));
55
+        $user->email 		= $request->get('email');
56
+        $user->password 	= Hash::make($request->get('password'));
57 57
 
58
-		$user->save();
58
+        $user->save();
59 59
 
60
-		return $this->success("The user with with id {$user->id} has been updated", 200);
61
-	}
60
+        return $this->success("The user with with id {$user->id} has been updated", 200);
61
+    }
62 62
 
63
-	public function destroy($id){
63
+    public function destroy($id){
64 64
 
65
-		$user = User::find($id);
65
+        $user = User::find($id);
66 66
 
67
-		if(!$user){
68
-			return $this->error("The user with {$id} doesn't exist", 404);
69
-		}
67
+        if(!$user){
68
+            return $this->error("The user with {$id} doesn't exist", 404);
69
+        }
70 70
 
71
-		$user->delete();
71
+        $user->delete();
72 72
 
73
-		return $this->success("The user with with id {$id} has been deleted", 200);
74
-	}
73
+        return $this->success("The user with with id {$id} has been deleted", 200);
74
+    }
75 75
 
76
-	public function validateRequest(Request $request){
76
+    public function validateRequest(Request $request){
77 77
 
78
-		$rules = [
79
-			'email' => 'required|email|unique:users', 
80
-			'password' => 'required|min:6'
81
-		];
78
+        $rules = [
79
+            'email' => 'required|email|unique:users', 
80
+            'password' => 'required|min:6'
81
+        ];
82 82
 
83
-		$this->validate($request, $rules);
84
-	}
83
+        $this->validate($request, $rules);
84
+    }
85 85
 
86
-	public function isAuthorized(Request $request){
86
+    public function isAuthorized(Request $request){
87 87
 
88
-		$resource = "users";
89
-		// $user     = User::find($this->getArgs($request)["user_id"]);
88
+        $resource = "users";
89
+        // $user     = User::find($this->getArgs($request)["user_id"]);
90 90
 
91
-		return $this->authorizeUser($request, $resource);
92
-	}
91
+        return $this->authorizeUser($request, $resource);
92
+    }
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@  discard block
 block discarded – undo
5 5
 use Illuminate\Http\Request;
6 6
 use Illuminate\Support\Facades\Hash;
7 7
 
8
-class UserController extends Controller{
8
+class UserController extends Controller {
9 9
 
10
-	public function __construct(){
10
+	public function __construct() {
11 11
 
12 12
 		$this->middleware('oauth', ['except' => ['index', 'show']]);
13 13
 		$this->middleware('authorize:' . __CLASS__, ['except' => ['index', 'show']]);
14 14
 	}
15 15
 
16
-	public function index(){
16
+	public function index() {
17 17
 
18 18
 		$users = User::all();
19 19
 		return $this->success($users, 200);
20 20
 	}
21 21
 
22
-	public function store(Request $request){
22
+	public function store(Request $request) {
23 23
 
24 24
 		$this->validateRequest($request);
25 25
 
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 		return $this->success("The user with with id {$user->id} has been created", 201);
32 32
 	}
33 33
 
34
-	public function show($id){
34
+	public function show($id) {
35 35
 
36 36
 		$user = User::find($id);
37 37
 
38
-		if(!$user){
38
+		if (!$user) {
39 39
 			return $this->error("The user with {$id} doesn't exist", 404);
40 40
 		}
41 41
 
42 42
 		return $this->success($user, 200);
43 43
 	}
44 44
 
45
-	public function update(Request $request, $id){
45
+	public function update(Request $request, $id) {
46 46
 
47 47
 		$user = User::find($id);
48 48
 
49
-		if(!$user){
49
+		if (!$user) {
50 50
 			return $this->error("The user with {$id} doesn't exist", 404);
51 51
 		}
52 52
 
53 53
 		$this->validateRequest($request);
54 54
 
55
-		$user->email 		= $request->get('email');
56
-		$user->password 	= Hash::make($request->get('password'));
55
+		$user->email = $request->get('email');
56
+		$user->password = Hash::make($request->get('password'));
57 57
 
58 58
 		$user->save();
59 59
 
60 60
 		return $this->success("The user with with id {$user->id} has been updated", 200);
61 61
 	}
62 62
 
63
-	public function destroy($id){
63
+	public function destroy($id) {
64 64
 
65 65
 		$user = User::find($id);
66 66
 
67
-		if(!$user){
67
+		if (!$user) {
68 68
 			return $this->error("The user with {$id} doesn't exist", 404);
69 69
 		}
70 70
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		return $this->success("The user with with id {$id} has been deleted", 200);
74 74
 	}
75 75
 
76
-	public function validateRequest(Request $request){
76
+	public function validateRequest(Request $request) {
77 77
 
78 78
 		$rules = [
79 79
 			'email' => 'required|email|unique:users', 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$this->validate($request, $rules);
84 84
 	}
85 85
 
86
-	public function isAuthorized(Request $request){
86
+	public function isAuthorized(Request $request) {
87 87
 
88 88
 		$resource = "users";
89 89
 		// $user     = User::find($this->getArgs($request)["user_id"]);
Please login to merge, or discard this patch.
app/Listeners/ExampleListener.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,6 @@
 block discarded – undo
3 3
 namespace App\Listeners;
4 4
 
5 5
 use App\Events\ExampleEvent;
6
-use Illuminate\Queue\InteractsWithQueue;
7
-use Illuminate\Contracts\Queue\ShouldQueue;
8 6
 
9 7
 class ExampleListener
10 8
 {
Please login to merge, or discard this patch.
app/User.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 use Illuminate\Database\Eloquent\Model;
8 8
 use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9 9
 use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
10
-
11 10
 use Illuminate\Support\Facades\Hash;
12 11
 
13 12
 class User extends Model implements AuthenticatableContract, AuthorizableContract{
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
      * @return int|boolean
41 41
      * @see    https://github.com/lucadegasperi/oauth2-server-laravel/blob/master/docs/authorization-server/password.md
42 42
      */
43
-    public function verify($email, $password){
43
+    public function verify($email, $password) {
44 44
 
45 45
         $user = User::where('email', $email)->first();
46 46
 
47
-        if($user && Hash::check($password, $user->password)){
47
+        if ($user && Hash::check($password, $user->password)) {
48 48
             return $user->id;
49 49
         }
50 50
 
Please login to merge, or discard this patch.
app/Comment.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@
 block discarded – undo
9 9
      *
10 10
      * @var array
11 11
      */
12
-	protected $fillable = ['id', 'post_id', 'user_id', 'content'];
12
+    protected $fillable = ['id', 'post_id', 'user_id', 'content'];
13 13
 
14 14
     /**
15 15
      * The attributes excluded from the model's JSON form.
16 16
      *
17 17
      * @var array
18 18
      */
19
-	protected $hidden   = ['created_at', 'updated_at'];
19
+    protected $hidden   = ['created_at', 'updated_at'];
20 20
 
21 21
     /**
22 22
      * Define an inverse one-to-many relationship with App\Post.
23 23
      *
24 24
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
25 25
      */
26
-	public function post(){
27
-		return $this->belongsTo('App\Post');
28
-	}
26
+    public function post(){
27
+        return $this->belongsTo('App\Post');
28
+    }
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 
5
-class Comment extends Model{
5
+class Comment extends Model {
6 6
 
7 7
     /**
8 8
      * The attributes that are mass assignable.
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @var array
18 18
      */
19
-	protected $hidden   = ['created_at', 'updated_at'];
19
+	protected $hidden = ['created_at', 'updated_at'];
20 20
 
21 21
     /**
22 22
      * Define an inverse one-to-many relationship with App\Post.
23 23
      *
24 24
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
25 25
      */
26
-	public function post(){
26
+	public function post() {
27 27
 		return $this->belongsTo('App\Post');
28 28
 	}
29 29
 
Please login to merge, or discard this patch.
app/Post.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@
 block discarded – undo
9 9
      *
10 10
      * @var array
11 11
      */
12
-	protected $fillable = ['id', 'user_id', 'title', 'content'];
12
+    protected $fillable = ['id', 'user_id', 'title', 'content'];
13 13
 
14 14
     /**
15 15
      * The attributes excluded from the model's JSON form.
16 16
      *
17 17
      * @var array
18 18
      */
19
-	protected $hidden   = ['created_at', 'updated_at'];
19
+    protected $hidden   = ['created_at', 'updated_at'];
20 20
 
21 21
     /**
22 22
      * Define a one-to-many relationship with App\Comment
23 23
      *
24 24
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
25 25
      */
26
-	public function comments(){
27
-		return $this->hasMany('App\Comment');
28
-	}
26
+    public function comments(){
27
+        return $this->hasMany('App\Comment');
28
+    }
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 
5
-class Post extends Model{
5
+class Post extends Model {
6 6
 
7 7
     /**
8 8
      * The attributes that are mass assignable.
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @var array
18 18
      */
19
-	protected $hidden   = ['created_at', 'updated_at'];
19
+	protected $hidden = ['created_at', 'updated_at'];
20 20
 
21 21
     /**
22 22
      * Define a one-to-many relationship with App\Comment
23 23
      *
24 24
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
25 25
      */
26
-	public function comments(){
26
+	public function comments() {
27 27
 		return $this->hasMany('App\Comment');
28 28
 	}
29 29
 
Please login to merge, or discard this patch.