/** @test */ public function it_unfollows_another_user() { // Given $users = TestDummy::times(2)->create('Larabook\\Users\\User'); // When $this->repository->follow($users[1]->id, $users[0]); $this->repository->unfollow($users[1]->id, $users[0]); // Then $this->tester->dontSeeRecord('follows', ['follower_id' => $users[0]->id, 'followed_id' => $users[1]->id]); }
/** * Handle the command. * * @param object $command * @return void */ public function handle($command) { $user = $this->userRepo->findById($command->userId); $this->userRepo->unfollow($command->userIdToUnfollow, $user); }
/** * Execute the job. * * @param $request * @param UserRepository $repository * @return mixed */ public function handle(UserRepository $repository) { $user = $repository->findById($this->userId); $repository->unfollow($this->userIdToUnfollow, $user); return $user; }
/** * Follow a Larabook user. * * @param $command * @return mixed */ public function handle($command) { $follower = $this->repository->findById($command->follower); $this->repository->unfollow($command->userToUnfollow, $follower); return $follower; }