File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change 99
1010trait Metable
1111{
12-
13- // Static property registration sigleton for save observation and slow large set hotfix
14- public static $ _isObserverRegistered ;
12+
1513 public static $ _columnNames ;
1614
1715 /**
@@ -194,20 +192,6 @@ public function whereMeta($key, $value)
194192 ->get ();
195193 }
196194
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-
211195 protected function getModelStub ()
212196 {
213197 // get new meta model instance
@@ -244,7 +228,6 @@ protected function saveMeta()
244228 protected function getMetaData ()
245229 {
246230 if (!isset ($ this ->metaLoaded )) {
247- $ this ->setObserver ();
248231
249232 if ($ this ->exists ) {
250233 $ objects = $ this ->metas
@@ -364,6 +347,12 @@ public function hasColumn($column) {
364347 if (empty (self ::$ _columnNames )) self ::$ _columnNames = array_map ('strtolower ' ,\Schema::connection ($ this ->getConnectionName ())->getColumnListing ($ this ->getTable ()));
365348 return in_array (strtolower ($ column ), self ::$ _columnNames );
366349 }
350+
351+ public static function bootMetable (){
352+ static ::saved (function ($ model ) {
353+ $ model ->saveMeta ();
354+ });
355+ }
367356
368357 public function __unset ($ key )
369358 {
You can’t perform that action at this time.
0 commit comments