Now i'm not familiar with the Request API so i can't confirm what $request->request->add([]); explicitly does but, make sure your form is accepting the enctype
<form method="POST" action="something" enctype="multipart/form-data">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I'm trying to find a good and easy way to store and update my images in the storage (s3 or public) and the according model's DB table. For example:
I have a Game model that is able to have 3 types of images
Now when I try to update that model and it's images, I don't seem to be able to do it properly.
This is the piece of code in my GameController@update I'm trying to do it with:
if ($request->logo && $file = Storage::putFileAs('images/games/logos', $request->file('logo'), $game->id)) {
$request->request->add(['logo' => $file]);
}
if ($request->banner && $file = Storage::putFileAs('images/games/banners', $request->file('banner'), $game->id)) {
$request->request->add(['banner' => $file]);
}
if ($request->poster && $file = Storage::putFileAs('images/games/posters', $request->file('poster'), $game->id)) {
$request->request->add(['poster' => $file]);
}
$request->request->add(['slug' => str_slug($request->name)]);
$game->update($request->all());
however when i return $request->all() before updating, it shows logo, banner and poster as "{}", even when I upload them with my form. When I return a single image for example return $file, I see the correct pathname 'images/games/logos/7' and it is storing the image correctly aswell.
So my question is is there a better way to do this or am I doing something wrong, because right now my images aren't being stored in the model's database table.
Why not just assign $request to another variable such as $data?
$data = $request->all();
$data['slug'] = str_slug('some-value');
$game->update($data);
EDIT:
Righteo, I checked out the API for Request. You can do:
// request() is the same as $request. It's just a helper
request()->merge([
'key' => 'value
]);
Please or to participate in this conversation.