/** * Display the content of the page * * @param $query * @return \Illuminate\View\View */ public function display($query) { $title = 'TestView'; $page = ""; $arr = explode('/', $query); // \App\Page::find(4)->content->find(5)->element->module->name $heading = \App\Node::findBySlug('header'); // dd(\App\Node::findBySlug($arr[0])->content); // test $content = \App\Node::active()->findBySlug($arr[0])->content; foreach ($content as $item) { // get the module Name of // $module = \App\Module::findOrFail($p->module_id); // resolve the Module Name out of the IOC Container and render the content partiall // $content .= App::make('module:' . $module->name)->render($p->content_id); // foreach ($item->content as $content) // { //Todo check if Module is Active and Content is Active $module = $item->element->module->name; if ($module != 'Heading') { continue; } // resolve the Module out of the IOC Container and render the partial $page .= App::make('module:' . strtolower($module))->render($item->element->row); // } } return view('layout.master', compact('title', 'page')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(NodeRequest $request) { $data = $request->all(); // todo: move to helper method $data['active'] = !empty($data['active']); // check if slug is empty if (empty($data['slug'])) { // create slug from name $data['slug'] = str_slug($data['name']); } // todo: create slug helper $exist = \App\Node::findBySlug($data['slug'])->get()->toArray(); if (!empty($exist)) { //$appendix = '-1'; dd($data, 'change slug'); } \App\Node::create($data)->save(); // todo: include flash // flash()->success('New node created!'); // todo: insert after logic return redirect()->route('admin.node.index'); }