Skip to content

Commit

Permalink
Merge branch 'master' into #247-email-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dpslwk committed Dec 24, 2018
2 parents e400dda + 5ba6577 commit 85eef90
Show file tree
Hide file tree
Showing 47 changed files with 2,285 additions and 621 deletions.
82 changes: 82 additions & 0 deletions app/Events/Labels/BoxPrint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace App\Events\Labels;

use Carbon\Carbon;
use HMS\Entities\Members\Box;
use Illuminate\Queue\SerializesModels;

class BoxPrint implements LabelPrintEventInterface
{
use SerializesModels;

/**
* @var string
*/
public $templateName;

/**
* @var array
*/
public $substitutions;

/**
* @var int
*/
public $copiesToPrint;

/**
* Create a new event instance.
*
* @param Box $box
* @param int $copiesToPrint
*/
public function __construct(Box $box,
$copiesToPrint = 1)
{
$this->templateName = 'member_box';
$this->copiesToPrint = $copiesToPrint;

// hack to offset the ID printing and give the look of right justification
$idOffset = (5 - strlen($box->getId())) * 35;

$this->substitutions = [
'memberName' => $box->getUser()->getFullname(),
'username' => $box->getUser()->getUsername(),
'lastDate' => Carbon::now()->toDateString(),
'qrURL' => route('user.boxes', ['user' => $box->getUser()->getId()]),
'idOffset' => 220 + $idOffset,
'memberBoxId' => $box->getId(),
];
}

/**
* Gets the value of templateName.
*
* @return string
*/
public function getTemplateName()
{
return $this->templateName;
}

/**
* Gets the value of substitutions.
*
* @return array
*/
public function getSubstitutions()
{
return $this->substitutions;
}

/**
* Gets the value of copiesToPrint.
*
* @return int
*/
public function getCopiesToPrint()
{
return $this->copiesToPrint;
}
}
26 changes: 26 additions & 0 deletions app/Events/Users/UserPasswordChanged.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Events\Users;

use HMS\Entities\User;
use Illuminate\Queue\SerializesModels;

class UserPasswordChanged
{
use SerializesModels;

/**
* @var User
*/
public $user;

/**
* Create a new event instance.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
}
11 changes: 11 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ class Handler extends ExceptionHandler
\Illuminate\Validation\ValidationException::class,
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
'currentPassword',
];

/**
* Report or log an exception.
*
Expand Down
10 changes: 10 additions & 0 deletions app/HMS/Entities/GateKeeper/Pin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ public function getState()
return $this->state;
}

/**
* Gets the value of state.
*
* @return string
*/
public function getStateString()
{
return PinState::STATE_STRINGS[$this->state];
}

/**
* Sets the value of state.
*
Expand Down
8 changes: 4 additions & 4 deletions app/HMS/Entities/GateKeeper/RfidTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RfidTag
*/
protected $lastUsed;
/**
* @var string
* @var null|string
*/
protected $friendlyName;

Expand Down Expand Up @@ -142,7 +142,7 @@ public function setState($state)
*/
public function getStateString()
{
return $this->statusStrings[$this->state];
return RfidTagState::STATE_STRINGS[$this->state];
}

/**
Expand All @@ -168,11 +168,11 @@ public function getFriendlyName()
/**
* Sets the value of friendlyName.
*
* @param string $friendlyName the friendly name
* @param null|string $friendlyName the friendly name
*
* @return self
*/
public function setFriendlyName(string $friendlyName)
public function setFriendlyName($friendlyName)
{
$this->friendlyName = $friendlyName;

Expand Down
4 changes: 2 additions & 2 deletions app/HMS/Entities/GateKeeper/RfidTagState.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class RfidTagState
const ACTIVE = 10;

/**
* RfidTag has expired and can no longer be used for entry.
* RfidTag has been destroyed and can no longer be used for entry.
*/
const EXPIRED = 20;

Expand All @@ -25,7 +25,7 @@ abstract class RfidTagState
const STATE_STRINGS =
[
self::ACTIVE => 'Active',
self::EXPIRED => 'Expired',
self::EXPIRED => 'Destroyed',
self::LOST => 'Lost',
];
}
2 changes: 1 addition & 1 deletion app/HMS/Entities/LabelTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LabelTemplate implements ArrayableContract
*/
public function updateWithRequest(LabelTemplateRequest $request)
{
$this->template_name = $request['template_name'];
$this->template_name = $request['templateName'];
$this->template = $request['template'];

return $this;
Expand Down
167 changes: 167 additions & 0 deletions app/HMS/Entities/Members/Box.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

namespace HMS\Entities\Members;

use Carbon\Carbon;
use HMS\Entities\User;

class Box
{
/**
* @var int
*/
protected $id;

/**
* @var Carbon
*/
protected $boughtDate;

/**
* @var null|Carbon
*/
protected $removedDate;

/**
* @var int
*/
protected $state;

/**
* @var User
*/
protected $user;

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return Carbon
*/
public function getBoughtDate()
{
return $this->boughtDate;
}

/**
* @param Carbon $boughtDate
*
* @return self
*/
public function setBoughtDate(Carbon $boughtDate)
{
$this->boughtDate = $boughtDate;

return $this;
}

/**
* @return null|Carbon
*/
public function getRemovedDate()
{
return $this->removedDate;
}

/**
* @param null|Carbon $removedDate
*
* @return self
*/
public function setRemovedDate(?Carbon $removedDate)
{
$this->removedDate = $removedDate;

return $this;
}

/**
* @return int
*/
public function getState()
{
return $this->state;
}

/**
* Gets the value of state.
*
* @return string
*/
public function getStateString()
{
return BoxState::STATE_STRINGS[$this->state];
}

/**
* @param int $state
*
* @return self
*/
public function setState($state)
{
if (array_key_exists($state, BoxState::STATE_STRINGS)) {
$this->state = $state;
}

return $this;
}

/**
* @return self
*/
public function setStateInUse()
{
$this->state = BoxState::INUSE;
$this->removedDate = null;

return $this;
}

/**
* @return self
*/
public function setStateRemoved()
{
$this->state = BoxState::REMOVED;
$this->removedDate = Carbon::now();

return $this;
}

/**
* @return self
*/
public function setStateAbandoned()
{
$this->state = BoxState::ABANDONED;
$this->removedDate = Carbon::now();

return $this;
}

/**
* @return User
*/
public function getUser()
{
return $this->user;
}

/**
* @param User $user
*
* @return self
*/
public function setUser(User $user)
{
$this->user = $user;

return $this;
}
}
Loading

0 comments on commit 85eef90

Please sign in to comment.