1 | <?php |
||
7 | class JoinColumn |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $relation; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $joinColumn; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $referenceColumn; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | protected $nullable = true; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $unique = false; |
||
33 | |||
34 | /** |
||
35 | * @var string|null |
||
36 | */ |
||
37 | protected $onDelete = null; |
||
38 | |||
39 | /** |
||
40 | * @var NamingStrategy |
||
41 | */ |
||
42 | protected $namingStrategy; |
||
43 | |||
44 | /** |
||
45 | * @param NamingStrategy $namingStrategy |
||
46 | * @param string $relation |
||
47 | * @param string|null $joinColumn |
||
48 | * @param string|null $referenceColumn |
||
49 | * @param bool $nullable |
||
50 | * @param bool $unique |
||
51 | * @param string|null $onDelete |
||
52 | */ |
||
53 | 67 | public function __construct( |
|
54 | NamingStrategy $namingStrategy, |
||
55 | $relation, |
||
56 | $joinColumn = null, |
||
57 | $referenceColumn = null, |
||
58 | $nullable = true, |
||
59 | $unique = false, |
||
60 | $onDelete = null |
||
61 | ) { |
||
62 | 67 | $this->joinColumn = $joinColumn; |
|
63 | 67 | $this->referenceColumn = $referenceColumn; |
|
64 | 67 | $this->relation = $relation; |
|
65 | 67 | $this->namingStrategy = $namingStrategy; |
|
66 | 67 | $this->nullable = $nullable; |
|
67 | 67 | $this->onDelete = $onDelete; |
|
68 | 67 | $this->unique = $unique; |
|
69 | 67 | } |
|
70 | |||
71 | /** |
||
72 | * @param string $foreignKey |
||
73 | * |
||
74 | * @return $this |
||
75 | */ |
||
76 | 4 | public function foreignKey($foreignKey) |
|
77 | { |
||
78 | 4 | $this->joinColumn = $foreignKey; |
|
79 | |||
80 | 4 | return $this; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param string $foreignKey |
||
85 | * |
||
86 | * @return $this |
||
87 | */ |
||
88 | 3 | public function target($foreignKey) |
|
92 | |||
93 | /** |
||
94 | * @param string $localKey |
||
95 | * |
||
96 | * @return $this |
||
97 | */ |
||
98 | 4 | public function localKey($localKey) |
|
99 | { |
||
100 | 4 | $this->referenceColumn = $localKey; |
|
101 | |||
102 | 4 | return $this; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * @param string $localKey |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | 3 | public function source($localKey) |
|
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | 48 | public function getJoinColumn() |
|
122 | |||
123 | /** |
||
124 | * @param string $joinColumn |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | 1 | public function setJoinColumn($joinColumn) |
|
129 | { |
||
130 | 1 | $this->joinColumn = $joinColumn; |
|
131 | |||
132 | 1 | return $this; |
|
133 | } |
||
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | 48 | public function getReferenceColumn() |
|
142 | |||
143 | /** |
||
144 | * @param string $referenceColumn |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | 1 | public function setReferenceColumn($referenceColumn) |
|
149 | { |
||
150 | 1 | $this->referenceColumn = $referenceColumn; |
|
151 | |||
152 | 1 | return $this; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * @return $this |
||
157 | */ |
||
158 | 2 | public function nullable() |
|
159 | { |
||
160 | 2 | $this->nullable = true; |
|
161 | |||
162 | 2 | return $this; |
|
163 | } |
||
164 | |||
165 | /** |
||
166 | * @return bool |
||
167 | */ |
||
168 | 46 | public function isNullable() |
|
172 | |||
173 | /** |
||
174 | * @return bool |
||
175 | */ |
||
176 | 46 | public function isUnique() |
|
180 | |||
181 | /** |
||
182 | * @return $this |
||
183 | */ |
||
184 | 2 | public function unique() |
|
185 | { |
||
186 | 2 | $this->unique = true; |
|
187 | |||
188 | 2 | return $this; |
|
189 | } |
||
190 | |||
191 | /** |
||
192 | * @return string|null |
||
193 | */ |
||
194 | 46 | public function getOnDelete() |
|
198 | |||
199 | /** |
||
200 | * @param string|null $onDelete |
||
201 | * |
||
202 | * @return $this |
||
203 | */ |
||
204 | 2 | public function onDelete($onDelete = null) |
|
205 | { |
||
210 | } |
||
211 |