/**
  * destroyVoucher function.
  *
  * @access public
  *
  * @param string $hash
  *
  * @return Voucher
  */
 public function destroyVoucher($hash)
 {
     if ($voucher = $this->model->where('hash', '=', $hash)->first()) {
         if ($voucher->delete()) {
             return $voucher;
         }
     }
     return false;
 }
 /**
  * expireVoucher function.
  *
  * @access public
  *
  * @param string $hash
  *
  * @return Voucher
  */
 public function expireVoucher($hash)
 {
     if ($voucher = $this->model->where('hash', '=', $hash)->first()) {
         $voucher->is_expired = 1;
         $voucher->expired_at = date('Y-m-d H:i:s');
         if ($voucher->save()) {
             return $voucher;
         }
     }
     return false;
 }
 /** @test **/
 public function itCanRedeemVoucher()
 {
     $repo = $this->getVoucherRepository();
     Voucher::create(['hash' => 'redeem001', 'campaign_id' => 1]);
     $voucher = $repo->redeemVoucher('redeem001');
     $this->assertInstanceOf('Fastwebmedia\\LaravelVouchering\\Models\\Voucher', $voucher);
     $this->assertEquals('1', $voucher->is_redeemed);
 }
 /** @test **/
 public function itCanGetCustomCampaignExpiryDate()
 {
     $repo = $this->getVoucherRepository();
     Voucher::create(['hash' => 'voucher002', 'campaign_id' => 1]);
     $voucher = $repo->loadVoucher('voucher002');
     $expected_date = date('Y-m-d H:i:s', strtotime($voucher->created_at . ' + 5 days'));
     $expiryDate = $voucher->getExpiryDate('5');
     $this->assertEquals($expected_date, $expiryDate);
 }