mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
987536930c
* Fix some n+1 problems * Use route in notification dropdown to make sure we link to correct page * Work on better UI support for checkout to non-user. Fix links on index bootstrap table, work towards eliminating assignedUser * Remove Asset::assigneduser() relationship. Instead add a checkedOutToUser() method and/or port to using assignedTo() * Adjust string to fit new reality * Fix #3780. Move the consumables getDataView method to the ApiController. Not entirely RESTful, but it's a weird method that probably doesn't need its own controller and the functionality would be strange to stack on the userscontroller... * Fix file uploads to assets and restore the delete route. * Add asset maintence edit action to index. * Suppliers asset list should link to the related asset, not to the supplier with same ID. * Asset models page should use polymorphic formatter on assigned to to better handle assorted item types. * Comment out more assigneduser fallacy until we figure out the query builder approach to searching for location text.
90 lines
1.8 KiB
PHP
90 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;
|
|
}
|
|
|
|
public function name() {
|
|
return $this->name;
|
|
}
|
|
}
|