Skip to content

Commit

Permalink
fix action models
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Aug 6, 2022
1 parent 7312981 commit 76579fe
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Traits/Actions/Bookmark/isBookmaker.php
Expand Up @@ -30,7 +30,7 @@ public function bookmark(Model $bookmarkable, array $data = null)
if ($bookmark = $this->getBookmark($bookmarkable)) {
return $bookmark->update(['data' => $data]);
} else {
return $this->bookmarks()->make(['bookmarker' => $this, 'data' => $data])->bookmarkable()->associate($bookmarkable)->save();
return $this->bookmarks()->make(['data' => $data])->bookmarkable()->associate($bookmarkable)->save();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Bookmark/isBookmarkable.php
Expand Up @@ -30,7 +30,7 @@ public function bookmarkBy(Authenticatable $bookmarker, array $data = null)
if ($bookmark = $this->getBookmark($bookmarker)) {
return $bookmark->update(['data' => $data]);
} else {
return $this->bookmarks()->make(['bookmarkable' => $this, 'data' => $data])->bookmarker()->associate($bookmarker)->save();
return $this->bookmarks()->make(['data' => $data])->bookmarker()->associate($bookmarker)->save();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Actions/Comment/isCommentable.php
Expand Up @@ -14,9 +14,9 @@ trait isCommentable
* @param string $comment
* @return boolean
*/
public function commentBy(Authenticatable $commenter, string $body)
public function commentBy(Authenticatable $commenter, string $comment)
{
return $this->comments()->make(['commentable' => $this, 'comment' => $body])->commenter()->associate($commenter)->save();
return $this->comments()->make(['comment' => $comment])->commenter()->associate($commenter)->save();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Actions/Comment/isCommenter.php
Expand Up @@ -14,9 +14,9 @@ trait isCommenter
* @param string $comment
* @return boolean
*/
public function comment(Model $commentable, string $body)
public function comment(Model $commentable, string $comment)
{
return $this->comments()->make(['commenter' => $this, 'comment' => $body])->commentable()->associate($commentable)->save();
return $this->comments()->make(['comment' => $comment])->commentable()->associate($commentable)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Favourite/isFavorer.php
Expand Up @@ -18,7 +18,7 @@ public function favourite(Model $favourable)
if ($this->favoured($favourable))
return true;

return $this->favourites()->make(['favorer' => $this])->favourable()->associate($favourable)->save();
return $this->favourites()->make()->favourable()->associate($favourable)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Favourite/isFavourable.php
Expand Up @@ -18,7 +18,7 @@ public function favouriteBy(Authenticatable $favorer)
if ($this->favouredBy($favorer))
return true;

return $this->favourites()->make(['favourable' => $this])->favorer()->associate($favorer)->save();
return $this->favourites()->make()->favorer()->associate($favorer)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Follow/isFollowable.php
Expand Up @@ -18,7 +18,7 @@ public function followBy(Authenticatable $follower)
if ($this->followedBy($follower))
return true;

return $this->follows()->make(['followable' => $this])->follower()->associate($follower)->save();
return $this->follows()->make()->follower()->associate($follower)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Follow/isFollower.php
Expand Up @@ -18,7 +18,7 @@ public function follow(Model $followable)
if ($this->followed($followable))
return true;

return $this->follows()->make(['follower' => $this])->followable()->associate($followable)->save();
return $this->follows()->make()->followable()->associate($followable)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Like/isLikeable.php
Expand Up @@ -18,7 +18,7 @@ public function likeBy(Authenticatable $liker)
if ($this->likedBy($liker))
return true;

return $this->likes()->make(['likeable' => $this])->liker()->associate($liker)->save();
return $this->likes()->make()->liker()->associate($liker)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Like/isLiker.php
Expand Up @@ -18,7 +18,7 @@ public function like(Model $likeable)
if ($this->liked($likeable))
return true;

return $this->likes()->make(['liker' => $this])->likeable()->associate($likeable)->save();
return $this->likes()->make()->likeable()->associate($likeable)->save();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Traits/Actions/Review/isReviewable.php
Expand Up @@ -35,7 +35,6 @@ public function reviewBy(Authenticatable $reviewer, float $rate = 0, string $com
]);
} else {
return $this->reviews()->make([
'reviewable' => $this,
'rate' => $rate,
'comment' => $comment
])->reviewer()->associate($reviewer)->save();
Expand Down
1 change: 0 additions & 1 deletion src/Traits/Actions/Review/isReviewer.php
Expand Up @@ -35,7 +35,6 @@ public function review(Model $reviewable, float $rate = 0, string $comment = nul
]);
} else {
return $this->reviews()->make([
'reviewer' => $this,
'rate' => $rate,
'comment' => $comment,
])->reviewable()->associate($reviewable)->save();
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Subscribe/isSubscribable.php
Expand Up @@ -18,7 +18,7 @@ public function subscribeBy(Authenticatable $subscriber)
if ($this->subscribedBy($subscriber))
return true;

return $this->subscriptions()->make(['subscribable' => $this])->subscriber()->associate($subscriber)->save();
return $this->subscriptions()->make()->subscriber()->associate($subscriber)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Actions/Subscribe/isSubscriber.php
Expand Up @@ -18,7 +18,7 @@ public function subscribe(Model $subscribable)
if ($this->subscribed($subscribable))
return true;

return $this->subscriptions()->make(['subscriber' => $this])->subscribable()->associate($subscribable)->save();
return $this->subscriptions()->make()->subscribable()->associate($subscribable)->save();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Actions/Vote/isVotable.php
Expand Up @@ -29,7 +29,7 @@ public function voteUpBy(Authenticatable $voter)
if ($vote = $this->getVote($voter)) {
return $vote->update(['vote' => true]);
} else {
return $this->votes()->make(['votable' => $this, 'vote' => true])->voter()->associate($voter)->save();
return $this->votes()->make(['vote' => true])->voter()->associate($voter)->save();
}
}

Expand All @@ -44,7 +44,7 @@ public function voteDownBy(Authenticatable $voter)
if ($vote = $this->getVote($voter)) {
return $vote->update(['vote' => false]);
} else {
return $this->votes()->make(['votable' => $this, 'vote' => false])->voter()->associate($voter)->save();
return $this->votes()->make(['vote' => false])->voter()->associate($voter)->save();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Actions/Vote/isVoter.php
Expand Up @@ -29,7 +29,7 @@ public function voteUp(Model $votable)
if ($vote = $this->getVote($votable)) {
return $vote->update(['vote' => true]);
} else {
return $this->votes()->make(['voter' => $this, 'vote' => true])->votable()->associate($votable)->save();
return $this->votes()->make(['vote' => true])->votable()->associate($votable)->save();
}
}

Expand All @@ -44,7 +44,7 @@ public function voteDown(Model $votable)
if ($vote = $this->getVote($votable)) {
return $vote->update(['vote' => false]);
} else {
return $this->votes()->make(['voter' => $this, 'vote' => false])->votable()->associate($votable)->save();
return $this->votes()->make(['vote' => false])->votable()->associate($votable)->save();
}
}

Expand Down

0 comments on commit 76579fe

Please sign in to comment.