public function store(Request $request)
{
$this->validate($request, [
'judul' => 'required',
'category_id' => 'required',
'konten' => 'required',
'gambar' => 'required',
]);
$gambar = $request->gambar;
$new_gambar = time().$gambar->getClientOriginalName();
$post = Posts::create([
'judul' => $request->judul,
'category_id' => $request->category_id,
'konten' => $request->konten,
'gambar' => 'public/uploads/posts/'.$new_gambar,
'slug' => Str::slug($request->judul),
'users_id' => Auth::id()
]);
$img = Image::make('public/uploads/',$gambar->getRealPath())->resize(300,
300)->保存('public/uploads/', $gambar->getClientOriginalName()); $gambar->move('上传', $new_gambar); $post->tags()->attach($request->tags);
return redirect('post');
}
慕仙森
繁星点点滴滴