mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-20 04:24:23 -08:00
bee1dfc4a6
* The default locale of en does not include dollar sign in default currency. Assume if there is no currency symbol set that the dollar sign is a good thing to look for in parsefloat. * Fix for 4485. Serial not serial_number Also fix bug where updating with a csv that does not include custom field columns should not overwrite current values. * Rename serial_number to serial in default imports to avoid needing to map weirdly. * Add Test for 4359. Not reproducable at current though
106 lines
2.1 KiB
PHP
106 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Helpers\Helper;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SnipeModel extends Model
|
|
{
|
|
// Setters that are appropriate across multiple models.
|
|
public function setPurchaseDateAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['purchase_date'] = $value;
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*/
|
|
public function setPurchaseCostAttribute($value)
|
|
{
|
|
$value = Helper::ParseFloat($value);
|
|
|
|
if ($value == '0.0') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['purchase_cost'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setLocationIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['location_id'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setCategoryIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['category_id'] = $value;
|
|
// dd($this->attributes);
|
|
return;
|
|
}
|
|
|
|
public function setSupplierIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['supplier_id'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setDepreciationIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['depreciation_id'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setManufacturerIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['manufacturer_id'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setMinAmtAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['min_amt'] = $value;
|
|
return;
|
|
}
|
|
|
|
public function setParentIdAttribute($value)
|
|
{
|
|
if ($value == '') {
|
|
$value = null;
|
|
}
|
|
$this->attributes['parent_id'] = $value;
|
|
return;
|
|
}
|
|
|
|
|
|
//
|
|
public function getDisplayNameAttribute()
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|