snipe-it/app/Models/SnipeModel.php
Laravel Shift 934afa036f Adopt Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
2021-06-10 20:15:52 +00:00

176 lines
3.4 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;
// dd($this->attributes);
}
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 setMinAmtAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['min_amt'] = $value;
}
public function setParentIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['parent_id'] = $value;
}
public function setFieldSetIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['fieldset_id'] = $value;
}
public function setCompanyIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['company_id'] = $value;
}
public function setWarrantyMonthsAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['warranty_months'] = $value;
}
public function setRtdLocationIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['rtd_location_id'] = $value;
}
public function setDepartmentIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['department_id'] = $value;
}
public function setManagerIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['manager_id'] = $value;
}
public function setModelIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['model_id'] = $value;
}
public function setStatusIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['status_id'] = $value;
}
//
public function getDisplayNameAttribute()
{
return $this->name;
}
}