| Total Complexity | 6 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class ProfileField extends ActiveModel |
||
| 20 | { |
||
| 21 | protected $casts = [ |
||
| 22 | 'id' => 'integer', |
||
| 23 | 'type' => 'string', |
||
| 24 | 'name' => 'serialize', |
||
| 25 | 'reg_exp' => 'string', |
||
| 26 | 'reg_cond' => 'string' |
||
| 27 | ]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get all table data using memory cache |
||
| 31 | * @param array $columns |
||
| 32 | * @return \Illuminate\Database\Eloquent\Collection|mixed|static[] |
||
| 33 | */ |
||
| 34 | public static function all($columns = ['*']) |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get field name locale by field id |
||
| 48 | * @param int $id |
||
| 49 | * @return array|null|string |
||
| 50 | */ |
||
| 51 | public static function getNameById($id) |
||
| 52 | { |
||
| 53 | $all = self::all(); |
||
| 54 | |||
| 55 | $record = $all->find($id); |
||
| 56 | if (!$record) { |
||
| 57 | return null; |
||
| 58 | } |
||
| 59 | |||
| 60 | return $record->getLocaled('name'); |
||
|
|
|||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Get field type by field id |
||
| 65 | * @param int $id |
||
| 66 | * @return array|null|string |
||
| 67 | */ |
||
| 68 | public static function getTypeById($id) |
||
| 78 | } |
||
| 79 | } |
||
| 80 |