public function patchSave($id, Request $request) { $widget = Text::findOrFail($id); $widget->update($request->all()); Session::flash('message', 'Text updated!'); return redirect('/admin/widgets/text/' . $id); }
public static function create($name) { if ($name == 'text') { $widget = Text::create(['title' => '', 'text' => '']); } if (!empty($widget)) { $widget->save(); return $widget; } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function getLayout($id) { Asset::add(['common/js/jquery.gridster.with-extras.js', 'admin/js/layout.js', 'common/css/gridster.min.css']); $page = Page::whereId($id)->first(); foreach ($page->widgets as &$widget) { if ($widget->widget_name == 'text') { $text = Text::whereId($widget->widget_id)->first(); $widget['title'] = $text['title']; $widget['text'] = $text['text']; } } return view('admin.pages.layout', ['page' => $page]); }