示例#1
0
 protected function removeDeprecatedPages()
 {
     foreach ($this->differ->deprecatedPages() as $pageName) {
         $page = Page::where('name', $pageName)->first();
         $page->delete();
     }
     return $this;
 }
示例#2
0
 /**
  *@test
  */
 public function the_content_repo_can_delete_a_page()
 {
     $contentRepo = new ContentRepository();
     $contentRepo::makePage('home');
     $this->assertCount(1, Page::where('name', 'home')->get());
     $contentRepo->deleteByName('home');
     $this->assertCount(0, Page::where('name', 'home')->get());
 }
 public function deleteByName($pageName)
 {
     $page = Page::where('name', $pageName)->firstOrFail();
     if ($page->textblocks->count() > 0) {
         $page->textblocks->each(function ($textblock) {
             $textblock->delete();
         });
     }
     if ($page->galleries->count() > 0) {
         $page->galleries->each(function ($gallery) {
             $gallery->delete();
         });
     }
     return $page->delete();
 }
 protected function seeBasicConfigInDatabase()
 {
     // $this->seeInDatabase('ec_pages', [
     //     'name' => 'home'
     // ]);
     $this->assertCount(1, Page::where('name', 'home')->get());
     $this->seeInDatabase('ec_pages', ['name' => 'about']);
     $this->seeInDatabase('ec_pages', ['name' => 'contact']);
     $this->seeInDatabase('ec_textblocks', ['name' => 'intro', 'description' => 'The homepage intro', 'allows_html' => 0]);
     $this->seeInDatabase('ec_textblocks', ['name' => 'intro', 'description' => 'The about page intro', 'allows_html' => 0]);
     $this->seeInDatabase('ec_textblocks', ['name' => 'spiel', 'description' => 'Company story', 'allows_html' => 1]);
     $this->seeInDatabase('ec_textblocks', ['name' => 'spiel', 'description' => 'My story', 'allows_html' => 1]);
     $this->seeInDatabase('ec_galleries', ['name' => 'slider', 'description' => 'Homepage banner slide images', 'is_single' => 0]);
     $this->seeInDatabase('ec_galleries', ['name' => 'slider', 'description' => 'About page banner slide images', 'is_single' => 0]);
 }
示例#5
0
 protected function notSeeInDatabase($table, $attributes)
 {
     switch ($table) {
         case 'ec_pages':
             $q = null;
             foreach ($attributes as $key => $value) {
                 if (is_null($q)) {
                     $q = Page::where($key, $value);
                 } else {
                     $q = $q->where($key, $value);
                 }
             }
             $this->assertCount(0, $q->get());
             break;
         case 'ec_textblocks':
             $q = null;
             foreach ($attributes as $key => $value) {
                 if (is_null($q)) {
                     $q = Textblock::where($key, $value);
                 } else {
                     $q = $q->where($key, $value);
                 }
             }
             $this->assertCount(0, $q->get());
             break;
         case 'ec_galleries':
             $q = null;
             foreach ($attributes as $key => $value) {
                 if (is_null($q)) {
                     $q = Gallery::where($key, $value);
                 } else {
                     $q = $q->where($key, $value);
                 }
             }
             $this->assertCount(0, $q->get());
             break;
         default:
             # code...
             break;
     }
 }