@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | * @return void |
16 | 16 | */ |
17 | 17 | public function up() |
18 | - { |
|
19 | - Schema::create('likes', function(Blueprint $table) { |
|
18 | + { |
|
19 | + Schema::create('likes', function(Blueprint $table) { |
|
20 | 20 | $table->id(); |
21 | - $table->morphs('likeable'); |
|
22 | - $table->unsignedBigInteger('user_id')->index(); |
|
21 | + $table->morphs('likeable'); |
|
22 | + $table->unsignedBigInteger('user_id')->index(); |
|
23 | 23 | $table->enum('type_id', [ |
24 | 24 | 'like', |
25 | 25 | 'dislike', |
26 | 26 | ])->default('like'); |
27 | - $table->timestamps(); |
|
27 | + $table->timestamps(); |
|
28 | 28 | |
29 | 29 | $table->unique([ |
30 | 30 | 'likeable_id', |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | 'user_id', |
33 | 33 | ], 'like_user_unique'); |
34 | 34 | |
35 | - }); |
|
35 | + }); |
|
36 | 36 | |
37 | - Schema::create('like_counters', function(Blueprint $table) { |
|
38 | - $table->id(); |
|
39 | - $table->morphs('likeable'); |
|
37 | + Schema::create('like_counters', function(Blueprint $table) { |
|
38 | + $table->id(); |
|
39 | + $table->morphs('likeable'); |
|
40 | 40 | $table->enum('type_id', [ |
41 | 41 | 'like', |
42 | 42 | 'dislike', |
43 | 43 | ])->default('like'); |
44 | - $table->unsignedBigInteger('count')->default(0); |
|
45 | - $table->timestamps(); |
|
44 | + $table->unsignedBigInteger('count')->default(0); |
|
45 | + $table->timestamps(); |
|
46 | 46 | |
47 | 47 | $table->unique([ |
48 | 48 | 'likeable_id', |
49 | 49 | 'likeable_type', |
50 | 50 | 'type_id', |
51 | 51 | ], 'like_counter_unique'); |
52 | - }); |
|
52 | + }); |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Reverse the migrations. |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @return void |
60 | 60 | */ |
61 | 61 | public function down() |
62 | - { |
|
63 | - Schema::drop('likes'); |
|
64 | - Schema::drop('like_counters'); |
|
65 | - } |
|
62 | + { |
|
63 | + Schema::drop('likes'); |
|
64 | + Schema::drop('like_counters'); |
|
65 | + } |
|
66 | 66 | } |
@@ -81,7 +81,7 @@ |
||
81 | 81 | */ |
82 | 82 | protected function registerPublishes() |
83 | 83 | { |
84 | - $databasePath = __DIR__.'./../migrations'; |
|
84 | + $databasePath = __DIR__ . './../migrations'; |
|
85 | 85 | $this->loadMigrationsFrom($databasePath); |
86 | 86 | |
87 | 87 | if ($this->app->runningInConsole()) { |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | { |
309 | 309 | $userId = $this->getLikerUserId($userId); |
310 | 310 | |
311 | - return $query->whereHas('likesAndDislikes', function (Builder $innerQuery) use ($type, $userId) { |
|
311 | + return $query->whereHas('likesAndDislikes', function(Builder $innerQuery) use ($type, $userId) { |
|
312 | 312 | $innerQuery->where('user_id', $userId); |
313 | 313 | $innerQuery->where('type_id', $this->getLikeTypeId($type)); |
314 | 314 | }); |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | return $query |
330 | 330 | ->select($likeable->getTable() . '.*', 'like_counter.count') |
331 | - ->leftJoin('like_counter', function (JoinClause $join) use ($likeable, $likeType) { |
|
331 | + ->leftJoin('like_counter', function(JoinClause $join) use ($likeable, $likeType) { |
|
332 | 332 | $join |
333 | 333 | ->on('like_counter.likeable_id', '=', "{$likeable->getTable()}.{$likeable->getKeyName()}") |
334 | 334 | ->where('like_counter.likeable_type', '=', $likeable->getMorphClass()) |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | continue; |
445 | 445 | } |
446 | 446 | |
447 | - return $likeable->{$relation}->contains(function ($item) use ($userId, $typeId) { |
|
447 | + return $likeable->{$relation}->contains(function($item) use ($userId, $typeId) { |
|
448 | 448 | return $item->user_id == $userId && $item->type_id === $typeId; |
449 | 449 | }); |
450 | 450 | } |
@@ -37,10 +37,10 @@ |
||
37 | 37 | /** |
38 | 38 | * @access private |
39 | 39 | */ |
40 | - public function likeable(): MorphTo |
|
41 | - { |
|
42 | - return $this->morphTo(); |
|
43 | - } |
|
40 | + public function likeable(): MorphTo |
|
41 | + { |
|
42 | + return $this->morphTo(); |
|
43 | + } |
|
44 | 44 | /** |
45 | 45 | * Return the like's author. |
46 | 46 | */ |
@@ -11,8 +11,8 @@ |
||
11 | 11 | */ |
12 | 12 | class LikeCounter extends Model implements LikeCounterContract |
13 | 13 | { |
14 | - protected $table = 'like_counters'; |
|
15 | - protected $fillable = [ |
|
14 | + protected $table = 'like_counters'; |
|
15 | + protected $fillable = [ |
|
16 | 16 | 'type_id', |
17 | 17 | 'count', |
18 | 18 | ]; |