本文整理汇总了PHP中app\helpers\Helper::ParseFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::ParseFloat方法的具体用法?PHP Helper::ParseFloat怎么用?PHP Helper::ParseFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\helpers\Helper
的用法示例。
在下文中一共展示了Helper::ParseFloat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createConsumableIfNotExists
/**
* Create a consumable if a duplicate does not exist
*
* @author Daniel Melzter
* @since 3.0
* @param $item array
*/
public function createConsumableIfNotExists(array $item)
{
$consumable = null;
$editingConsumable = false;
$this->log("Creating Consumable");
foreach ($this->consumables as $tempconsumable) {
if (strcasecmp($tempconsumable->name, $item["item_name"]) == 0) {
$this->log("A matching consumable " . $item["item_name"] . " already exists");
if (!$this->option('update')) {
$this->log("Skipping consumable.");
return;
}
$this->log('Updating matching consumable with new values');
$editingConsumable = true;
$consumable = $tempconsumable;
}
}
if (is_null($consumable)) {
$this->log("No matching consumable, creating one");
$consumable = new Consumable();
}
if (!$editingConsumable) {
$consumable->name = $item["item_name"];
}
if (!empty($item["purchase_date"])) {
$consumable->purchase_date = $item["purchase_date"];
} else {
$consumable->purchase_date = null;
}
if (!empty($item["purchase_cost"])) {
$consumable->purchase_cost = Helper::ParseFloat($item["purchase_cost"]);
}
if ($item["location"]) {
$consumable->location_id = $item["location"]->id;
}
$consumable->user_id = $this->option('user_id');
if ($item["company"]) {
$consumable->company_id = $item["company"]->id;
}
if (!empty($item["order_number"])) {
$consumable->order_number = $item["order_number"];
}
if ($item["category"]) {
$consumable->category_id = $item["category"]->id;
}
// TODO:Implement
//$consumable->notes= e($item_notes);
if (!empty($item["requestable"])) {
$consumable->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
}
if (!empty($item["quantity"])) {
if ($item["quantity"] > -1) {
$consumable->qty = $item["quantity"];
} else {
$consumable->qty = 1;
}
}
if (!$this->option("testrun")) {
// dd($consumable);
if ($consumable->save()) {
$this->log("Consumable " . $item["item_name"] . ' was created');
// $this->comment("Consumable " . $item["item_name"] . ' was created');
} else {
$this->jsonError('Consumable', $consumable->getErrors());
}
} else {
$this->log('TEST RUN - Consumable ' . $item['item_name'] . ' not created');
}
}