本文整理匯總了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');
}
}