public function setPageIdAttribute($value)
 {
     if (!isset($this->attributes['name'])) {
         \App::setLocale('es');
         if ($page = \Solunes\Master\App\Page::find($value)) {
             $page_name = $page->name;
         } else {
             $page_name = '-';
         }
         $this->attributes['name'] = $page_name;
     }
     $this->attributes['page_id'] = $value;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Solunes\Master\App\ImageSize::truncate();
     \Solunes\Master\App\ImageFolder::truncate();
     \Solunes\Master\App\TempFile::truncate();
     \Solunes\Master\App\VariableTranslation::truncate();
     \Solunes\Master\App\Variable::truncate();
     \Solunes\Master\App\InboxUser::truncate();
     \Solunes\Master\App\InboxMessage::truncate();
     \Solunes\Master\App\Inbox::truncate();
     \Solunes\Master\App\Notification::truncate();
     \Solunes\Master\App\Activity::truncate();
     DB::table('permission_role')->truncate();
     DB::table('role_user')->truncate();
     \Solunes\Master\App\Role::truncate();
     \Solunes\Master\App\Permission::truncate();
     \App\User::truncate();
     \Solunes\Master\App\EmailTranslation::truncate();
     \Solunes\Master\App\Email::truncate();
     \Solunes\Master\App\IndicatorValue::truncate();
     \Solunes\Master\App\IndicatorGraph::truncate();
     \Solunes\Master\App\IndicatorAlert::truncate();
     \Solunes\Master\App\Indicator::truncate();
     \Solunes\Master\App\FieldOptionTranslation::truncate();
     \Solunes\Master\App\FieldOption::truncate();
     \Solunes\Master\App\FieldConditional::truncate();
     \Solunes\Master\App\FieldExtra::truncate();
     \Solunes\Master\App\FieldTranslation::truncate();
     \Solunes\Master\App\Field::truncate();
     \Solunes\Master\App\Section::truncate();
     \Solunes\Master\App\Filter::truncate();
     \Solunes\Master\App\NodeExtra::truncate();
     \Solunes\Master\App\NodeRequest::truncate();
     \Solunes\Master\App\NodeTranslation::truncate();
     \Solunes\Master\App\Node::truncate();
     \Solunes\Master\App\MenuTranslation::truncate();
     \Solunes\Master\App\Menu::truncate();
     \Solunes\Master\App\PageTranslation::truncate();
     \Solunes\Master\App\Page::truncate();
     \Solunes\Master\App\SiteTranslation::truncate();
     \Solunes\Master\App\Site::truncate();
     \Solunes\Master\App\Language::truncate();
     \App\PasswordReminder::truncate();
 }
<?php

Route::get('sitemap.xml', function () {
    // create new sitemap object
    $sitemap = App::make("sitemap");
    $sitemap->setCache('laravel.sitemap', 3600);
    if (!$sitemap->isCached()) {
        foreach (\Solunes\Master\App\Language::get() as $lang) {
            \App::setLocale($lang->code);
            foreach (\Solunes\Master\App\Page::get() as $page) {
                if ($page->id == 1) {
                    $priority = '1.0';
                } else {
                    $priority = '0.9';
                }
                $sitemap->add($page->translate($lang->code)->slug, $page->created_at, $priority, 'daily');
            }
            $node_array = \CustomFunc::get_sitemap_array($lang->code);
            if (count($node_array) > 0) {
                foreach ($node_array as $node_key => $node_item) {
                    $node = \Solunes\Master\App\Node::where('name', $node_key)->first();
                    $node_model = $node->model;
                    foreach ($node_model::orderBy('created_at', 'desc')->get() as $post) {
                        $sitemap->add($node_item['url'] . $post->{$node_item}['url_id'], $post->created_at, $node_item['priority'], 'monthly');
                    }
                }
            }
        }
    }
    return $sitemap->render('xml');
});