File tree 1 file changed +7
-18
lines changed
1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change 9
9
10
10
trait Metable
11
11
{
12
-
13
- // Static property registration sigleton for save observation and slow large set hotfix
14
- public static $ _isObserverRegistered ;
12
+
15
13
public static $ _columnNames ;
16
14
17
15
/**
@@ -194,20 +192,6 @@ public function whereMeta($key, $value)
194
192
->get ();
195
193
}
196
194
197
- /**
198
- * Trait specific functions
199
- * -------------------------.
200
- */
201
- protected function setObserver ()
202
- {
203
- if (!isset (self ::$ _isObserverRegistered )) {
204
- $ this ->saved (function ($ model ) {
205
- $ model ->saveMeta ();
206
- });
207
- self ::$ _isObserverRegistered = true ;
208
- }
209
- }
210
-
211
195
protected function getModelStub ()
212
196
{
213
197
// get new meta model instance
@@ -244,7 +228,6 @@ protected function saveMeta()
244
228
protected function getMetaData ()
245
229
{
246
230
if (!isset ($ this ->metaLoaded )) {
247
- $ this ->setObserver ();
248
231
249
232
if ($ this ->exists ) {
250
233
$ objects = $ this ->metas
@@ -364,6 +347,12 @@ public function hasColumn($column) {
364
347
if (empty (self ::$ _columnNames )) self ::$ _columnNames = array_map ('strtolower ' ,\Schema::connection ($ this ->getConnectionName ())->getColumnListing ($ this ->getTable ()));
365
348
return in_array (strtolower ($ column ), self ::$ _columnNames );
366
349
}
350
+
351
+ public static function bootMetable (){
352
+ static ::saved (function ($ model ) {
353
+ $ model ->saveMeta ();
354
+ });
355
+ }
367
356
368
357
public function __unset ($ key )
369
358
{
You can’t perform that action at this time.
0 commit comments