Пример #1
0
 public function update(PageRequest $request, $id = 0)
 {
     $page = Page::findOrFail($id);
     $page->update(['url' => $request->get('url'), 'view' => $request->get('view'), 'views' => $request->get('views'), 'is_open' => $request->get('is_open'), 'openurl' => $request->get('openurl'), 'cover' => $request->get('cover'), 'thumb' => $request->get('thumb'), 'hash' => $request->get('hash')]);
     if ($page) {
         Cache::store('page')->flush();
         Attachment::where(['hash' => $page->hash, 'project_id' => 0])->update(['project_id' => $page->id]);
         $message = '单页修改成功,请选择操作!';
         $url = [];
         $url['返回单页列表'] = ['url' => route('admin.pages.index')];
         $url['继续添加'] = ['url' => route('admin.pages.create')];
         $url['继续编辑'] = ['url' => route('admin.pages.edit', $page->id)];
         $url['查看单页'] = ['url' => route('page.show', $page->url), 'target' => '_blank'];
         return Theme::view('admin.message.show', compact('message', 'url'));
     }
 }
 /**
  * Update the specified resource in storage.
  * @param   string      $slug
  * @param   PageRequest $request
  * @return  Response
  */
 public function update($slug, PageRequest $request)
 {
     // Update
     $status = Page::findBySlugOrFail($slug, false)->update($request->only('title', 'slug', 'content', 'published', 'user_id'));
     // Flash message
     if ($status) {
         Flash::success('Updated', "The page '" . $request->get('title') . "' was successfully updated.");
     } else {
         Flash::error('Error', "Something went wrong while trying to update the page '" . $request->get('title') . "'.");
     }
     // Redirect
     return redirect(route('page.index'));
 }