snipe-it/app/Models/SnipeModel.php

77 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use App\Helpers\Helper;
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;
}
/**
* @param $value
*/
public function setPurchaseCostAttribute($value)
{
$value = Helper::ParseFloat($value);
if($value == '0.0') {
$value = null;
}
$this->attributes['purchase_cost'] = $value;
}
public function setLocationIdAttribute($value)
{
if($value == '') {
$value = null;
}
$this->attributes['location_id'] = $value;
}
public function setCategoryIdAttribute($value)
{
if($value == '') {
$value = null;
}
$this->attributes['category_id'] = $value;
}
public function setSupplierIdAttribute($value)
{
if($value == '') {
$value = null;
}
$this->attributes['supplier_id'] = $value;
}
public function setDepreciationIdAttribute($value)
{
if($value == '') {
$value = null;
}
$this->attributes['depreciation_id'] = $value;
}
public function setManufacturerIdAttribute($value)
{
if($value == '') {
$value = null;
}
$this->attributes['manufacturer_id'] = $value;
}
//
public function getDisplayNameAttribute()
{
return $this->name;
}
}