'Can't generate faker image in Laravel
I have a problem with my code. I try to generate a faker image in Laravel 8, but it's not showing like the image in my path.
PostFactory
class PostFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->sentence(mt_rand(2, 8)),
'slug' => $this->faker->slug(),
'excerpt' => $this->faker->paragraph(),
'image' => $this->faker
->image('public/img/posts', 640, 480, null, false),
'body' => $this->faker->paragraph(mt_rand(5, 10)),
'user_id' => mt_rand(1, 3),
'category_id' => mt_rand(1, 2)
];
}
}
Blade/View
<img width="600" class="rounded" src="/img/posts/{{ $post->image }}"
alt="/img/posts/{{ $post->image }}">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
