Esempio n. 1
0
 /**
  * Load all blocks from database and events.
  * Blocks collection will stored in this class.
  *
  * return void
  */
 private function initBlocks()
 {
     // get block
     //        $databaseBlocks = Block::with(['menu', 'menu.items'])->whereActive(true)->orderBy('range', 'asc')->get();
     $databaseBlocks = Block::with(['menu', 'menu.items'])->orderBy('range', 'asc')->get();
     $eventBlocks = event('loadEventBlocks');
     // TODO maybe use here the filter function
     // merge event blocks
     foreach ($eventBlocks as $eventBlock) {
         if (is_null($eventBlock)) {
             continue;
         }
         if ($eventBlock->active == false) {
             // not active
             continue;
         }
         $databaseBlocks->push($eventBlock);
     }
     // group by area
     $this->blocks = $databaseBlocks->filter(function ($block) {
         if (is_null($block)) {
             return false;
         }
         // check exception rule
         $ex = new Exception($block);
         return $ex->isViewable();
     })->sortBy('range')->groupBy('area');
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function check_relation()
 {
     $menu = factory(Menu::class)->create();
     $block = factory(\Alpaca\Block\Models\Block::class)->create(['menu_id' => $menu->id]);
     // check relation
     $this->assertEquals(Menu::first()->block->first()->id, $block->id);
     $this->assertEquals(Block::first()->menu->first()->id, $menu->id);
 }
Esempio n. 3
0
 /**
  * Remove a block.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $result = Block::destroy($id);
     flashDelete($result, trans('block::block.block'));
     return redirect(route('block.index'));
 }