Initial commit
This commit is contained in:
42
app/Models/CustomField.php
Normal file
42
app/Models/CustomField.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CustomField extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const TYPE_TEXT = 'text';
|
||||
public const TYPE_NUMBER = 'number';
|
||||
public const TYPE_DATE = 'date';
|
||||
public const TYPE_SELECT = 'select';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'field_type',
|
||||
'options',
|
||||
'applies_to_issue_types',
|
||||
'is_required',
|
||||
'display_order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'applies_to_issue_types' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
];
|
||||
|
||||
public function values(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomFieldValue::class);
|
||||
}
|
||||
|
||||
public function appliesToIssueType(string $issueType): bool
|
||||
{
|
||||
return in_array($issueType, $this->applies_to_issue_types ?? []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user