snipe-it/app/Models/SnipeModel.php
Daniel Meltzer ae0573b3da Fix asset create (#3929)
* Fix accidental commit of ImporterTest.

* Move the name() method to the presenter

This fixes some weird collisions between laravels voodoo and our
presenter voodoo that confused php.  It's also probably a cleaner place
to put it.  Should fix #3927

* Add missing parenthesis

* Add heading to tables on locations/view page.
2017-09-06 16:24:43 -07:00

86 lines
1.8 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 getDisplayNameAttribute()
{
return $this->name;
}
}