Hi laracsats, im working on a multiple-image form. i am able to upload, and save the image in the database, and on the image path in the public folder, but my problem is displaying the multiple images in view, each time I tried I only get the image path and the image unique names, but they arent displaying, but if I remove the protected casts in the post model and upload, the images will display once I add back the protected cast and refresh the browse. please help
here is my controller
,,,
public function store(Request $req)
{
$data = $req->validate([
'images' => 'required|array',
'images.*' => 'mimes:jpeg,jpg,png,gif,csv,txt,pdf|max:10048',
'body' => 'required|string|min:15|max:100',
'location' => 'required',
'category' => 'required',
]);
$images = [];
$user_id = Auth::user()->id;
$body = $req->input('body');
$location = $req->input('location');
$category = $req->input('category');
if ($req->hasfile('images')) {
foreach ($req->file('images') as $file) {
$name = uniqid() . '.' . $file->extension();
$file->move(public_path() . '/uploads/', $name);
$imgData[] = $name;
}
$post = new POST();
$post->user_id = auth()->id(); // add this line
$post->body = $body;
$post->location = $location;
$post->category = $category;
$post->name = json_encode($imgData);
$post->images = json_encode($imgData);
$post->save();
return back()->with('success', 'post created successfully!');
}
}
'''
here is my model