Example #1
0
 public function destroy($slug, $id)
 {
     $menu = Menu::getSlugOrFail($slug);
     $result = $menu->items()->destroy($id);
     flashDelete($result, trans('menu::menu.menuitem'));
     return redirect(route('menu.show', $slug));
 }
Example #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);
 }
Example #3
0
 /**
  * @test
  */
 public function check_relation()
 {
     // create
     $menu = factory(\Alpaca\Menu\Models\Menu::class)->create();
     $item = factory(\Alpaca\Menu\Models\Item::class)->create(['menu_id' => $menu->id]);
     // check relation
     $this->assertEquals(Menu::first()->items->first()->id, $item->id);
     $this->assertEquals(Item::first()->menu->id, $menu->id);
 }
Example #4
0
 /**
  * Formbuilder.
  *
  * @param null $form
  * @param \Illuminate\Database\Eloquent\Model|null $entry
  *
  * @return mixed
  */
 public function getForm($form = null, Model $entry = null)
 {
     $selectedArea = null;
     $selectedRange = null;
     $selectedMenu = null;
     if (!is_null($entry)) {
         // only for edit
         $selectedArea = $entry->area;
         $selectedRange = $entry->range;
         if (!empty($entry->menu->id)) {
             $selectedMenu = $entry->menu->id;
         }
     }
     $menus = Menu::orderBy('title', 'asc')->pluck('title', 'id');
     $menus->prepend(trans('menu::menu.no_menu'), '');
     $formFields = ['id' => $form->hidden('id'), 'name' => $form->text(trans('crud::crud.name'), 'name'), 'title' => $form->text(trans('crud::crud.title'), 'title'), 'active' => $form->checkbox(trans('page::page.active'), 'active')->defaultToChecked(), 'mobile_view' => $form->checkbox(trans('block::block.mobile_view'), 'mobile_view')->defaultToChecked(), 'desktop_view' => $form->checkbox(trans('block::block.desktop_view'), 'desktop_view')->defaultToChecked(), 'desktop_view_force' => $form->checkbox(trans('block::block.desktop_view_force'), 'desktop_view_force'), 'area' => $form->select(trans('block::block.area'), 'area')->options($this->getAreaChoice())->select($selectedArea), 'range' => $form->select(trans('block::block.range'), 'range')->options(Block::RANGES)->select($selectedRange), 'menu_id' => $form->select(trans('menu::menu.menu'), 'menu_id')->options($menus)->select($selectedMenu), 'html' => $form->textarea(trans('crud::crud.body'), 'html')->addClass('is-summernote'), 'exception_rule_exclude' => $form->radio(trans('block::block.exclude_site'), 'exception_rule', Block::EXCEPTION_EXCLUDE)->checked(), 'exception_rule_only' => $form->radio(trans('block::block.include_site'), 'exception_rule', Block::EXCEPTION_ONLY), 'exception' => $form->textarea(trans('block::block.exception'), 'exception')->helpBlock(trans('block::block.exception_help_text')), 'submit' => $form->submit(trans('crud::crud.save'))];
     return $formFields;
 }
Example #5
0
 /**
  * Edit a block.
  *
  * @param int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $block = Block::findOrFail($id);
     $menus = Menu::select();
     return view('block::form', compact('block', 'menus'));
 }
Example #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $result = Menu::destroy($id);
     flashDelete($result, trans('menu::menu.menu'));
     return redirect(route('menu.index'));
 }