1: <?php
2:
3: /**
4: * Deep
5: *
6: * @package rsanchez\Deep
7: * @author Rob Sanchez <info@robsanchez.com>
8: */
9:
10: namespace rsanchez\Deep\Model;
11:
12: use rsanchez\Deep\Model\AbstractField;
13: use rsanchez\Deep\Collection\FieldCollection;
14:
15: /**
16: * Model for the channel_fields table
17: */
18: class Field extends AbstractField
19: {
20: /**
21: * {@inheritdoc}
22: *
23: * @var string
24: */
25: protected $table = 'channel_fields';
26:
27: /**
28: * {@inheritdoc}
29: *
30: * @var string
31: */
32: protected $primaryKey = 'group_id';
33:
34: /**
35: * {@inheritdoc}
36: *
37: * @param array $fields
38: * @return \rsanchez\Deep\Collection\FieldCollection
39: */
40: public function newCollection(array $fields = array())
41: {
42: return new FieldCollection($fields);
43: }
44:
45: public function hasRows()
46: {
47: return $this->field_type === 'matrix' || $this->field_type === 'grid';
48: }
49:
50: /**
51: * {@inheritdoc}
52: */
53: public function getName()
54: {
55: return $this->field_name;
56: }
57:
58: /**
59: * {@inheritdoc}
60: */
61: public function getIdentifier()
62: {
63: return 'field_id_'.$this->field_id;
64: }
65:
66: /**
67: * {@inheritdoc}
68: */
69: public function getId()
70: {
71: return $this->field_id;
72: }
73:
74: /**
75: * {@inheritdoc}
76: */
77: public function getType()
78: {
79: return $this->field_type;
80: }
81: }
82: