Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, $id)
 {
     //
     $all = $request->all();
     if (!isset($all['id']) || !$all['id']) {
         $all['Users_id'] = \Session::get('id', null);
     }
     $model = new \App\Article();
     if (isset($all['_token'])) {
     }
     unset($all["_token"]);
     $intro = explode('。', strip_tags($all["content"]), 1);
     $intro = implode('。', $intro) . "...";
     $all["intro"] = $intro;
     if ($id && !$model->isExist($id)) {
         $result = $model->newArticle($all);
     }
     $all['id'] = $id;
     $all['updated_at'] = Carbon::now();
     $result = $model->modifyArticle($all);
     if ($request) {
         echo '<script>window.location.href=\'/admin/home\';</script>';
     }
 }