Example #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(PostCreateRequest $request)
 {
     $data['posts_title'] = $request->input('posts_title');
     $data['posts_description'] = addslashes($request->input('posts_description'));
     $data['website'] = $request->input('website');
     $data['project'] = $request->input('project');
     $data['posts_content'] = $request->input('posts_content');
     $id = Post::insertGetId($data);
     if ($id) {
         return response()->json(['status' => true, 'message' => '数据插入成功', 'data' => $data]);
     } else {
         return response()->json(['status' => false, 'message' => '数据插入失败']);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  PostRequest  $request
  * @return Response
  */
 public function store(PostCreateRequest $request)
 {
     $post = Auth::user()->posts()->create($request->all());
     $post->slug = str_slug($post->title, "-");
     $post->save();
     $post->tags()->attach($request->input('tag_list'));
     flash()->overlay('Your post has been successfully created!', 'Good job');
     return redirect('posts/postsAuth');
 }