Blame view
app/User/BanCreator.php
1.22 KB
e77200db5 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<?php namespace FootyRoom\User; use FootyRoom\Repositories\BanRepository; class BanCreator { /** * @var \FootyRoom\Repositories\BanRepository */ protected $banRepo; /** * Constructor. * * @param \FootyRoom\Repositories\BanRepository $banRepo */ public function __construct(BanRepository $banRepo) { $this->banRepo = $banRepo; } /** * Creates new ban or updates existing one if it's still active. * * @param string $entityType Something like 'user_id' or 'cookieId' * @param string|int $entityId If of the entity being banned. * @param string $type Type of ban. * @param int $duration Duration in seconds. * @param int $createdBy User id of the ban creator. * * @return bool */ public function create($entityType, $entityId, $type, $duration, $creator) { // Check if such ban already exists. $ban = $this->banRepo->findActive($entityType, $entityId, $type); // Edit this ban if it exists. if ($ban) { return $this->banRepo->resetDuration($ban->id, $duration); } return $this->banRepo->create($entityType, $entityId, $type, $duration, $creator); } } |