FEATURE: change directory structure
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomField
|
||||
*/
|
||||
class CustomField extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'type_id',
|
||||
'resource_id',
|
||||
'description',
|
||||
'possible_values',
|
||||
'default_value',
|
||||
'regexp',
|
||||
'min_length',
|
||||
'max_length',
|
||||
'required'
|
||||
];
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Getter for all custom fields indexed by resource ID.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexedByResource()
|
||||
{
|
||||
// find all records in table
|
||||
$fields = CustomField::all();
|
||||
|
||||
// add them to array indexed by resource ID
|
||||
$customFields = [];
|
||||
foreach ($fields as $field) {
|
||||
$customFields[$field->resource_id][] = $field;
|
||||
}
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user