mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
48 lines
919 B
PHP
48 lines
919 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Import extends Model
|
|
{
|
|
protected $casts = [
|
|
'header_row' => 'array',
|
|
'first_row' => 'array',
|
|
'field_map' => 'json',
|
|
];
|
|
|
|
protected function delimiter(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
set: function ($value) {
|
|
if ($value == 'semicolon') {
|
|
return ';';
|
|
}
|
|
if ($value == 'pipe') {
|
|
return '|';
|
|
}
|
|
|
|
return ',';
|
|
|
|
},
|
|
|
|
get: function ($value) {
|
|
if ($value == 'semicolon') {
|
|
return ';';
|
|
}
|
|
if ($value == 'pipe') {
|
|
return '|';
|
|
}
|
|
|
|
return ',';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
}
|
|
}
|