File tree Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public function likedBy(User $user)
2222
2323 public function dislikedBy (User $ user )
2424 {
25- optional ($ this ->likes ()->where ('user_id ' , $ user ->id )->get ()-> first ())->delete ();
25+ optional ($ this ->likes ()->where ('user_id ' , $ user ->id )->first ())->delete ();
2626 }
2727
2828 public function likes (): MorphMany
@@ -32,10 +32,6 @@ public function likes(): MorphMany
3232
3333 public function isLikedBy (User $ user ): bool
3434 {
35- if ($ user == null ) {
36- return false ;
37- }
38-
3935 return $ this ->likes ()->where ('user_id ' , $ user ->id )->exists ();
4036 }
4137
Original file line number Diff line number Diff line change 66
77class CreateLikesTable extends Migration
88{
9- /**
10- * Run the migrations.
11- *
12- * @return void
13- */
149 public function up ()
1510 {
1611 Schema::create ('likes ' , function (Blueprint $ table ) {
@@ -20,15 +15,12 @@ public function up()
2015 $ table ->string ('likeable_type ' );
2116 $ table ->timestamps ();
2217 });
23- }
2418
25- /**
26- * Reverse the migrations.
27- *
28- * @return void
29- */
30- public function down ()
31- {
32- Schema::dropIfExists ('likes ' );
19+ Schema::table ('subscriptions ' , function (Blueprint $ table ) {
20+ $ table ->index (['user_id ' , 'uuid ' ]);
21+ $ table ->foreign ('user_id ' )
22+ ->references ('id ' )->on ('users ' )
23+ ->onDelete ('CASCADE ' );
24+ });
3325 }
3426}
You can’t perform that action at this time.
0 commit comments