图像无法显示。
$table->string('image');
这是我将数据迁移到db时使用的方法。
public function store(CreatePostsRequest $request)
{
// upload the image to storage
$image = $request->image->store('posts');
// create the post
$post = Post::create([
'title' => $request->title,
'description' => $request->description,
'content' => $request->content,
'image' => $image,
'published_at' => $request->published_at,
'category_id' => $request->category
]);
if ($request->tags) {
$post->tags()->attach($request->tags);
}
// flash a message
session()->flash('success', 'Post Created Successfully.');
// Redirect
return redirect(route('posts.index'));
}