Example #1
0
 public static function newUser($dbc, $fn, $ln, $email, $pwd, $sa, $pc, $DOB, $gender)
 {
     $instance = new self($email, $pwd);
     $instance->fill($fn, $ln, $sa, $pc, $DOB, $gender);
     $instance->insertUser($dbc);
     return $instance;
 }
Example #2
0
 public static function instantiate(User $admin, array $data)
 {
     $instance = new self();
     $instance->author()->associate($admin);
     $instance->fill($data)->save();
     return $instance;
 }
Example #3
0
 public static function fromRow(array $row)
 {
     // 'constructor' using db query row
     $instance = new self();
     $instance->fill($row);
     return $instance;
 }
 public static function instantiate($seller, array $data)
 {
     $instance = new self();
     $instance->seller()->associate($seller);
     $instance->fill($data)->save();
     return $instance;
 }
Example #5
0
 /**
  * Create an Order
  *
  * @param array $items
  * @param $user_id
  *
  * @return Order
  */
 public function order($user_id, $data = null)
 {
     $order = new self();
     $order->user_id = $user_id;
     $order->items_number = 0;
     $order->items_total = 0;
     if ($data) {
         $order->fill($data);
     }
     $order->state = config("shop.status_init");
     $order->save();
     return $order;
 }
Example #6
0
    /**
     * Load the material type by the given id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`materialTypeId`,
				`name`
			FROM materialTypes
			WHERE `materialTypeId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $materialType = \query($sql);
        $obj = new self();
        $obj->fill($materialType);
        return $obj;
    }
Example #7
0
    /**
     * Load a material by ID
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`materialId`,
				`materialTypeId`,
				`name`,
				additional
			FROM materials
			WHERE `materialId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $material = \query($sql);
        $obj = new self();
        $obj->fill($material);
        $obj->loadMaterialAssets();
        return $obj;
    }
Example #8
0
    /**
     * Load an item type by its id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`itemTypeId`,
				`name`,
				`type`,
				`talentPoints`,
				`time`
			FROM itemTypes
			WHERE `itemTypeId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $itemType = query($sql);
        $obj = new self();
        $obj->fill($itemType);
        return $obj;
    }
Example #9
0
 /**
  * Create an Order
  *
  * @param array $items
  * @param $user_id
  *
  * @return Order
  */
 public function order($user_id, $data = null, $draft = FALSE)
 {
     $order = new self();
     $order->user_id = $user_id;
     $order->items_number = 0;
     $order->items_total = 0;
     if ($data) {
         $order->fill($data);
     }
     if (!$draft) {
         $order = $this->removeInvalidAttributes($order);
         $order->state = config("order.init");
         $order->save();
     } else {
         //Allocate fake id
         $order->state = 'draft';
         $order->id = 0;
     }
     return $order;
 }
Example #10
0
    /**
     * Load a technique by the given id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`techniqueId`,
				`name`,
				`timeFactor`,
				`priceFactor`,
				proof,
				`breakFactor`,
				`hitPoints`,
				`noOtherAllowed`,
				unsellable
			FROM techniques
			WHERE `techniqueId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $technique = query($sql);
        $obj = new self();
        $obj->fill($technique);
        return $obj;
    }
Example #11
0
 public static function instantiate(User $user, array $data, array $tags = [])
 {
     $instance = new self();
     $instance->author()->associate($user);
     $instance->fill($data)->save();
     if ($tags) {
         $instance->tags()->attach($tags);
     }
     return $instance;
 }
Example #12
0
 public static function fromRow(array $row)
 {
     $instance = new self();
     $instance->fill($row);
     return $instance;
 }
Example #13
0
 public static function withDetails($aUserLogin, $aUserFirstName, $aUserLastName, $aUserEmail, $aUserPhone, $aCampName, $aCampDescription, $aCampConstruction, $aCampParticipants, $aCampShortDesc, $aWorkshop1, $aWorkshop2, $aWorkshop3, $aWorkshop4)
 {
     $instance = new self();
     $instance->fill($aUserLogin, $aUserFirstName, $aUserLastName, $aUserEmail, $aUserPhone, $aCampName, $aCampDescription, $aCampConstruction, $aCampParticipants, $aCampShortDesc, $aWorkshop1, $aWorkshop2, $aWorkshop3, $aWorkshop4);
     return $instance;
 }
 /**
  * Set opacity of current image
  *
  * @param  integer $transparency
  * @return Image
  */
 public function opacity($transparency)
 {
     if ($transparency >= 0 && $transparency <= 100) {
         $transparency = intval($transparency) / 100;
     } else {
         throw new Exception('Opacity must be between 0 and 100');
     }
     // create alpha mask
     $alpha = new self(null, $this->width, $this->height);
     $alpha->fill(sprintf('rgba(0, 0, 0, %.1f)', $transparency));
     // apply alpha mask
     $this->mask($alpha, true);
     return $this;
 }
Example #15
0
    /**
     * Load an item by its id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`itemId`,
				`name`,
				`itemType`,
				`price`,
				`twoHanded`,
				`improvisational`,
				`privileged`,
				`hitPointsDice`,
				`hitPointsDiceType`,
				`hitPoints`,
				`damageType`,
				`breakFactor`,
				`initiative`,
				`weaponModificator`,
				`weight`,
				`physicalStrengthRequirement`
			FROM items
			WHERE `itemId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $item = query($sql);
        $obj = new self();
        $obj->fill($item);
        return $obj;
    }
Example #16
0
 public static function instantiate(array $data)
 {
     $instance = new self();
     $instance->fill($data)->save();
     return $instance;
 }
Example #17
0
 public function offsetSet($offset, $value)
 {
     list($nrow, $ncol) = $this->count();
     $offsets = array();
     if (is_null($offset)) {
         $offset = $nrow;
     }
     $this->_offsetChecker($offset, $offsets);
     list($rowstart, $rowend, $colstart, $colend) = $offsets;
     $vm = null;
     if (!is_array($value)) {
         $vm = new self();
         $vm->fill($value, $rowend - $rowstart + 1, $colend - $colstart + 1);
     } else {
         if (!$value instanceof Matrix) {
             $vm = new self($value);
         } else {
             $vm = $value;
         }
     }
     list($vrow, $vcol) = $vm->count();
     if ($vrow != $rowend - $rowstart + 1 or $vcol != $colend - $colstart + 1) {
         throw new \InvalidArgumentException('Inconsistent dimension.');
     }
     $mrowend = max($rowend, $nrow - 1);
     $mcolend = max($colend, $ncol - 1);
     for ($i = 0; $i <= $mrowend; $i++) {
         for ($j = 0; $j <= $mcolend; $j++) {
             if ($i >= $rowstart and $i <= $rowend and $j >= $colstart and $j <= $colend) {
                 $this->data[$i][$j] = $vm->get($i - $rowstart, $j - $colstart);
             } elseif ($i >= $nrow or $j >= $ncol) {
                 $this->data[$i][$j] = 0;
             }
         }
     }
 }
Example #18
0
 public static function newUser($data, $type = 'C')
 {
     $validate = self::validateUser($data, $type);
     if ($validate->fails()) {
         $response['messages'] = $validate->messages()->toArray();
         $response['return_code'] = 406;
         return $response;
     }
     $user = new self();
     if (!empty($data['password'])) {
         $data['password'] = bcrypt($data['password']);
     }
     $user->fill($data);
     $user->save();
     $user->token = \Crypt::encrypt(['id_users' => $user->id_users]);
     $response = ['user' => $user, 'return_code' => 201];
     return $response;
 }
Example #19
0
    /**
     * Load a material asset by its id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`materialAssetId`,
				percentage,
				`timeFactor`,
				`priceFactor`,
				`priceWeight`,
				proof,
				`breakFactor`,
				`hitPoints`,
				armor,
				`weaponModificator`
			FROM materialAssets
			WHERE `materialAssetId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $materialAsset = query($sql);
        $obj = new self();
        $obj->fill($materialAsset);
        return $obj;
    }
Example #20
0
    /**
     * Load the blueprint for the given id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`blueprintId`,
				`name`,
				`itemId`,
				`itemTypeId`,
				`damageType`,
				`materialWeaponModificator`,
				`upgradeHitPoints`,
				`upgradeBreakFactor`,
				`upgradeInitiative`,
				`upgradeWeaponModificator`,
				`bonusRangedFightValue`,
				`reducePhysicalStrengthRequirement`
			FROM blueprints
			WHERE `blueprintId` = ' . \sqlval($id) . '
				AND !`deleted`
		';
        $blueprint = query($sql);
        $obj = new self();
        $obj->fill($blueprint);
        $obj->loadMaterials();
        $obj->loadTechniques();
        return $obj;
    }
Example #21
0
 /**
  * Set opacity of current image
  *
  * @param  integer $transparency
  * @return Image
  */
 public function opacity($transparency)
 {
     if (is_numeric($transparency) && $transparency >= 0 && $transparency <= 100) {
         $transparency = intval($transparency) / 100;
     } else {
         throw new Exception\OpacityOutOfBoundsException('Opacity must be between 0 and 100');
     }
     // --------------------------------------------------------------------
     // http://stackoverflow.com/questions/2396415/what-does-new-self-mean-in-php
     // --------------------------------------------------------------------
     // create alpha mask
     $alpha = new self(null, $this->width, $this->height);
     $alpha->fill(sprintf('rgba(0, 0, 0, %.1f)', $transparency));
     // apply alpha mask
     $this->mask($alpha, true);
     return $this;
 }
Example #22
0
    /**
     * Load a character by the given id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`characterId`,
				`key`,
				`lastUpdate`,
				`name`,
				`bowMaking`,
				`precisionMechanics`,
				blacksmith,
				woodworking,
				leatherworking,
				tailoring
			FROM characters
			WHERE `characterId` = ' . sqlval($id) . '
				AND !deleted
		';
        $character = query($sql);
        $obj = new self();
        $obj->fill($character);
        return $obj;
    }
Example #23
0
 public static function instantiate(User $user, $parent, $data)
 {
     $instance = new self();
     $instance->author()->associate($user);
     if ($parent instanceof Post) {
         $instance->post()->associate($parent);
     } elseif ($parent instanceof Comment) {
         $instance->post_id = $parent->post_id;
     }
     $instance->fill($data)->save();
     if ($parent instanceof Comment) {
         $instance->makeChildOf($parent);
     }
     return $instance;
 }
Example #24
0
    /**
     * Load a crafting by its id.
     *
     * @param integer $id
     *
     * @return \self
     */
    public static function loadById($id)
    {
        $sql = '
			SELECT
				`craftingId`,
				`blueprintId`,
				`characterId`,
				`name`,
				`notes`,
				`toolsProofModificator`,
				`planProofModificator`,
				`doneProofs`,
				`done`
			FROM craftings
			WHERE `craftingId` = ' . \sqlval($id) . '
				AND !deleted
		';
        $crafting = \query($sql);
        $obj = new self();
        $obj->fill($crafting);
        $obj->loadTalentPoints();
        return $obj;
    }