Completed
Push — master ( 78665f...8b7dd5 )
by Carlos
11s
created
src/FollowRelation.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@
 block discarded – undo
47 47
     public function scopePopular($query, $type = null)
48 48
     {
49 49
         $query->select('followable_id', 'followable_type', \DB::raw('COUNT(*) AS count'))
50
-                     ->groupBy('followable_id', 'followable_type')
51
-                     ->orderByDesc('count');
50
+                        ->groupBy('followable_id', 'followable_type')
51
+                        ->orderByDesc('count');
52 52
 
53 53
         if ($type) {
54 54
             $query->where('followable_type', $this->normalizeFollowableType($type));
Please login to merge, or discard this patch.
src/Traits/CanBeVoted.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@  discard block
 block discarded – undo
30 30
         return Follow::isRelationExists($this, 'voters', $user);
31 31
     }
32 32
 	
33
-	/**
34
-	 * Check if item is upvoted by given user.
35
-	 *
36
-	 * @param int $user
37
-	 *
38
-	 * @return bool
39
-	 */
40
-	public function isUpvotedBy($user)
41
-	{
42
-		return Follow::isRelationExists($this, 'upvoters', $user);
43
-	}
33
+    /**
34
+     * Check if item is upvoted by given user.
35
+     *
36
+     * @param int $user
37
+     *
38
+     * @return bool
39
+     */
40
+    public function isUpvotedBy($user)
41
+    {
42
+        return Follow::isRelationExists($this, 'upvoters', $user);
43
+    }
44 44
 	
45
-	/**
46
-	 * Check if item is downvoted by given user.
47
-	 *
48
-	 * @param int $user
49
-	 *
50
-	 * @return bool
51
-	 */
52
-	public function isDownvotedBy($user)
53
-	{
54
-		return Follow::isRelationExists($this, 'downvoters', $user);
55
-	}
45
+    /**
46
+     * Check if item is downvoted by given user.
47
+     *
48
+     * @param int $user
49
+     *
50
+     * @return bool
51
+     */
52
+    public function isDownvotedBy($user)
53
+    {
54
+        return Follow::isRelationExists($this, 'downvoters', $user);
55
+    }
56 56
 
57 57
     /**
58 58
      * Return voters.
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
                     ->withPivot('followable_type', 'relation', 'created_at');
67 67
     }
68 68
 	
69
-	/**
70
-	 * Return upvoters.
71
-	 *
72
-	 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
73
-	 */
74
-	public function upvoters()
75
-	{
76
-		return $this->morphToMany(config('follow.user_model'), config('follow.morph_prefix'), config('follow.followable_table'))
77
-		            ->wherePivot('relation', '=', Follow::RELATION_UPVOTE)
78
-		            ->withPivot('followable_type', 'relation', 'created_at');
79
-	}
69
+    /**
70
+     * Return upvoters.
71
+     *
72
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
73
+     */
74
+    public function upvoters()
75
+    {
76
+        return $this->morphToMany(config('follow.user_model'), config('follow.morph_prefix'), config('follow.followable_table'))
77
+                    ->wherePivot('relation', '=', Follow::RELATION_UPVOTE)
78
+                    ->withPivot('followable_type', 'relation', 'created_at');
79
+    }
80 80
 	
81
-	/**
82
-	 * Return downvoters.
83
-	 *
84
-	 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
85
-	 */
86
-	public function downvoters()
87
-	{
88
-		return $this->morphToMany(config('follow.user_model'), config('follow.morph_prefix'), config('follow.followable_table'))
89
-		            ->wherePivot('relation', '=', Follow::RELATION_DOWNVOTE)
90
-		            ->withPivot('followable_type', 'relation', 'created_at');
91
-	}
81
+    /**
82
+     * Return downvoters.
83
+     *
84
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
85
+     */
86
+    public function downvoters()
87
+    {
88
+        return $this->morphToMany(config('follow.user_model'), config('follow.morph_prefix'), config('follow.followable_table'))
89
+                    ->wherePivot('relation', '=', Follow::RELATION_DOWNVOTE)
90
+                    ->withPivot('followable_type', 'relation', 'created_at');
91
+    }
92 92
 }
Please login to merge, or discard this patch.
src/Traits/CanVote.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -29,38 +29,38 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function vote($targets, $type = 'upvote', $class = __CLASS__)
31 31
     {
32
-	    $this->cancelVote($targets);
32
+        $this->cancelVote($targets);
33 33
     	
34 34
         return Follow::attachRelations($this, str_plural($type), $targets, $class);
35 35
     }
36 36
 	
37
-	/**
38
-	 * Upvote an item or items.
39
-	 *
40
-	 * @param int|array|\Illuminate\Database\Eloquent\Model $targets
41
-	 * @param string                                        $type
42
-	 * @param string                                        $class
43
-	 *
44
-	 * @return array
45
-	 */
46
-	public function upvote($targets, $class = __CLASS__)
47
-	{
48
-		return $this->vote($targets, 'upvote', $class);
49
-	}
37
+    /**
38
+     * Upvote an item or items.
39
+     *
40
+     * @param int|array|\Illuminate\Database\Eloquent\Model $targets
41
+     * @param string                                        $type
42
+     * @param string                                        $class
43
+     *
44
+     * @return array
45
+     */
46
+    public function upvote($targets, $class = __CLASS__)
47
+    {
48
+        return $this->vote($targets, 'upvote', $class);
49
+    }
50 50
 	
51
-	/**
52
-	 * Downvote an item or items.
53
-	 *
54
-	 * @param int|array|\Illuminate\Database\Eloquent\Model $targets
55
-	 * @param string                                        $type
56
-	 * @param string                                        $class
57
-	 *
58
-	 * @return array
59
-	 */
60
-	public function downvote($targets, $class = __CLASS__)
61
-	{
62
-		return $this->vote($targets, 'downvote', $class);
63
-	}
51
+    /**
52
+     * Downvote an item or items.
53
+     *
54
+     * @param int|array|\Illuminate\Database\Eloquent\Model $targets
55
+     * @param string                                        $type
56
+     * @param string                                        $class
57
+     *
58
+     * @return array
59
+     */
60
+    public function downvote($targets, $class = __CLASS__)
61
+    {
62
+        return $this->vote($targets, 'downvote', $class);
63
+    }
64 64
 
65 65
     /**
66 66
      * Cancel vote for an item or items.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         Follow::detachRelations($this, 'upvotes', $targets, $class);
76 76
         Follow::detachRelations($this, 'downvotes', $targets, $class);
77 77
 	
78
-	    return $this;
78
+        return $this;
79 79
     }
80 80
 
81 81
     /**
@@ -91,32 +91,32 @@  discard block
 block discarded – undo
91 91
         return Follow::isRelationExists($this, 'upvote', $target, $class);
92 92
     }
93 93
 	
94
-	/**
95
-	 * Check if user is downvoted given item.
96
-	 *
97
-	 * @param int|array|\Illuminate\Database\Eloquent\Model $target
98
-	 * @param string                                        $class
99
-	 *
100
-	 * @return bool
101
-	 */
102
-	public function hasDownvoted($target, $class = __CLASS__)
103
-	{
104
-		return Follow::isRelationExists($this, 'downvote', $target, $class);
105
-	}
94
+    /**
95
+     * Check if user is downvoted given item.
96
+     *
97
+     * @param int|array|\Illuminate\Database\Eloquent\Model $target
98
+     * @param string                                        $class
99
+     *
100
+     * @return bool
101
+     */
102
+    public function hasDownvoted($target, $class = __CLASS__)
103
+    {
104
+        return Follow::isRelationExists($this, 'downvote', $target, $class);
105
+    }
106 106
 	
107
-	/**
108
-	 * Return item votes.
109
-	 *
110
-	 * @param string $class
111
-	 *
112
-	 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
113
-	 */
114
-	public function votes($class = __CLASS__)
115
-	{
116
-		return $this->morphedByMany($class, config('follow.morph_prefix'), config('follow.followable_table'))
117
-					->wherePivotIn('relation', [Follow::RELATION_UPVOTE, Follow::RELATION_DOWNVOTE])
118
-		            ->withPivot('followable_type', 'relation', 'created_at');
119
-	}
107
+    /**
108
+     * Return item votes.
109
+     *
110
+     * @param string $class
111
+     *
112
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
113
+     */
114
+    public function votes($class = __CLASS__)
115
+    {
116
+        return $this->morphedByMany($class, config('follow.morph_prefix'), config('follow.followable_table'))
117
+                    ->wherePivotIn('relation', [Follow::RELATION_UPVOTE, Follow::RELATION_DOWNVOTE])
118
+                    ->withPivot('followable_type', 'relation', 'created_at');
119
+    }
120 120
 
121 121
     /**
122 122
      * Return item upvotes.
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
                     ->withPivot('followable_type', 'relation', 'created_at');
133 133
     }
134 134
 	
135
-	/**
136
-	 * Return item downvotes.
137
-	 *
138
-	 * @param string $class
139
-	 *
140
-	 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
141
-	 */
142
-	public function downvotes($class = __CLASS__)
143
-	{
144
-		return $this->morphedByMany($class, config('follow.morph_prefix'), config('follow.followable_table'))
145
-		            ->wherePivot('relation', '=', Follow::RELATION_DOWNVOTE)
146
-		            ->withPivot('followable_type', 'relation', 'created_at');
147
-	}
135
+    /**
136
+     * Return item downvotes.
137
+     *
138
+     * @param string $class
139
+     *
140
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
141
+     */
142
+    public function downvotes($class = __CLASS__)
143
+    {
144
+        return $this->morphedByMany($class, config('follow.morph_prefix'), config('follow.followable_table'))
145
+                    ->wherePivot('relation', '=', Follow::RELATION_DOWNVOTE)
146
+                    ->withPivot('followable_type', 'relation', 'created_at');
147
+    }
148 148
 }
Please login to merge, or discard this patch.