Beispiel #1
0
 /**
  * @param DataMapper $mapper
  * @param User $user
  * @param string $type
  * @return Token
  */
 public function createToken(DataMapper $mapper, User $user, $type)
 {
     $this->assert($mapper->getEntityClass() == Token::class);
     $code = preg_replace('/[^a-zA-Z0-9\\_\\-]+/', null, Rand::getString(100));
     return $mapper->create(['user' => $user, 'code' => sprintf('%d.%d.%s', $user->getId(), time(), $code), 'type' => $type]);
 }
Beispiel #2
0
 /**
  * @param DataMapper $mapper
  * @param callable $filter
  * @return \Doctrine\ORM\Query
  */
 public function queryStockItems(DataMapper $mapper, callable $filter = null)
 {
     $this->assert($mapper->getEntityClass() == StockItem::class);
     $builder = $mapper->select();
     $builder->addSelect('st, su, uu');
     $builder->leftJoin('sti.type', 'st');
     $builder->leftJoin('sti.storage_unit', 'su');
     $builder->leftJoin('sti.usage_unit', 'uu');
     if ($filter) {
         $filter($builder);
     }
     return $builder->getQuery();
 }
Beispiel #3
0
 /**
  * @param DataMapper $mapper
  * @return IngredientType[]
  */
 public function createDefaultIngredientType(DataMapper $mapper)
 {
     $this->assert($mapper->getEntityClass() == IngredientType::class);
     return $mapper->createMany([['name' => 'Bahan Makanan'], ['name' => 'Pengolahan'], ['name' => 'Pelengkap'], ['name' => 'Lainnya']]);
 }
Beispiel #4
0
 /**
  * @param DataMapper $mapper
  * @return Account
  * @throws \Doctrine\ORM\NoResultException
  */
 public function getAccount(DataMapper $mapper)
 {
     $this->assert($mapper->getEntityClass() == Account::class);
     return $mapper->one(1);
 }