Пример #1
0
 /**
  * On update, update children uris
  * 
  * @param  Page $model
  * @return void
  */
 public function updating(Page $model)
 {
     if ($model->isDirty('parent_id')) {
         foreach (Config::get('app.locales') as $locale) {
             $model->translate($locale)->uri = '';
         }
     }
 }
Пример #2
0
 /**
  * Recursive method for emptying children’s uri
  * UriObserver will rebuild uris.
  *
  * @param Page $page
  *
  * @return void
  */
 public function resetChildrenUri(Page $page)
 {
     foreach ($page->children as $childPage) {
         foreach (config('translatable.locales') as $locale) {
             if (is_null($page->translate($locale)->uri)) {
                 $childPage->translate($locale)->uri = null;
             } else {
                 $childPage->translate($locale)->uri = '';
             }
         }
         $childPage->save();
         $this->resetChildrenUri($childPage);
     }
 }