/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $article->user_id = Auth::id();
     $picture = "";
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $picture = sha1($filename . time()) . '.' . $extension;
     }
     $article->picture = $picture;
     $article->update($request->except('image'));
     if (Input::hasFile('image')) {
         $destinationPath = base_path() . '/images/article/' . $article->id . '/';
         Input::file('image')->move($destinationPath, $picture);
     }
 }
 /**
  * Update the specified article in storage.
  *
  * @param Article $article
  * @param ArticleRequest $request
  * @return Response
  */
 public function update(Article $article, ArticleRequest $request)
 {
     $article->fill($request->all());
     $article->save() ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
     return redirect(route('admin.article.index'));
 }
 /**
  * 添加文章
  *
  * @param Request $request
  * @author yangyifan <*****@*****.**>
  */
 public function postAdd(ArticleRequest $request)
 {
     $data = $request->all();
     //写入数据
     $affected_number = ForumModel::create($data);
     return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/forum/index')) : $this->response(400, trans('response.add_error'), [], false);
 }
 /**
  * 添加文章
  *
  * @param Request $request
  * @auther yangyifan <*****@*****.**>
  */
 public function postAdd(ArticleRequest $request)
 {
     $data = $request->all();
     //写入当前用户到数据
     $data['admin_info_id'] = $request->get('admin_info_id', Session::get('admin_info.id'));
     //写入数据
     $affected_number = ArticleModel::create($data);
     return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/article/index')) : $this->response(400, trans('response.add_error'), [], false);
 }
Пример #5
0
 public function postUpdate(Requests\Admin\ArticleRequest $request, $type, $act, $id = 0)
 {
     $article = new Article();
     if ($act == 'edit') {
         $article = Article::find($id);
     }
     $article->user_id = \Auth::id();
     $article->node_id = $request->input('node');
     $article->title = $request->input('title');
     $article->seo_title = $request->input('seo_title');
     $article->description = $request->input('description');
     $article->keywords = $request->input('keywords');
     $article->type = $request->input('type');
     $article->image = $request->input('get_image');
     $article->outline = $request->input('outline') ?: str_limit(strip_tags($request->input('content')));
     $article->content = $request->input('content');
     $article->order = $request->input('order');
     $article->views = $request->input('views');
     $article->hot = $request->input('hot') ? 1 : 0;
     $article->status = $request->input('status') ? 1 : 0;
     $article->recommend = $request->input('recommend') ? 1 : 0;
     $article->show_index = $request->input('show_index') ? 1 : 0;
     if ($article->save()) {
         $info = ['from' => 'update', 'status' => 'success'];
         j4flash($info);
         return redirect('admin/article/index/' . $type);
     } else {
         return redirect()->back()->withErrors(['err' => lang('submit failed')])->withInput();
     }
 }