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 Illuminate\Database\Eloquent\Model;
13: use Illuminate\Database\Eloquent\Builder;
14: use rsanchez\Deep\Model\AbstractProperty;
15: use rsanchez\Deep\Collection\GridColCollection;
16:
17: /**
18: * Model for the grid_columns table
19: */
20: class GridCol extends AbstractProperty
21: {
22: /**
23: * {@inheritdoc}
24: *
25: * @var string
26: */
27: protected $table = 'grid_columns';
28:
29: /**
30: * {@inheritdoc}
31: *
32: * @var string
33: */
34: protected $primaryKey = 'col_id';
35:
36: /**
37: * Filter by Field ID
38: *
39: * @param \Illuminate\Database\Eloquent\Builder $query
40: * @param int|array $fieldId
41: * @return \Illuminate\Database\Eloquent\Builder
42: */
43: public function scopeFieldId(Builder $query, $fieldId)
44: {
45: $fieldId = is_array($fieldId) ? $fieldId : array($fieldId);
46:
47: return $this->whereIn('field_id', $fieldId);
48: }
49:
50: /**
51: * {@inheritdoc}
52: *
53: * @param array $models
54: * @return \rsanchez\Deep\Collection\GridColCollection
55: */
56: public function newCollection(array $models = array())
57: {
58: return new GridColCollection($models);
59: }
60:
61: /**
62: * {@inheritdoc}
63: */
64: public function getName()
65: {
66: return $this->col_name;
67: }
68:
69: /**
70: * {@inheritdoc}
71: */
72: public function getIdentifier()
73: {
74: return 'col_id_'.$this->col_id;
75: }
76:
77: /**
78: * {@inheritdoc}
79: */
80: public function getId()
81: {
82: return $this->col_id;
83: }
84:
85: /**
86: * {@inheritdoc}
87: */
88: public function getType()
89: {
90: return $this->col_type;
91: }
92: }
93: