Couple of things that I could see happening here.
- Never being stored.
When you say its a temp file, usually temp files exist when the file is uploaded but never moved. So, I would just throw a quick dd('icon is ok'); in here...
if ($request->hasFile('icon') && $request->file('icon')->isValid()) {
dd('icon is ok');
...
That way you can check that this code is actually going to be executed.
If it shows up that its ok, you know that its got to do with the storage mechanism and not the if logic.
Next, it looks like you are trying to store the file in the 'icon' folder, but you need to give a fully-qualified directory, so if you have a folder structure public/icon you need to ensure that it gets the full directory structure. To do that, you can just use the public_path helper function.
So what you would do is...
public function update(Request $request, User $user, Role $role)
{
$user->update($request->all());
if($request->input('password')) {
$user->password = Hash::make($request->input('password'));
}
if ($request->hasFile('icon') && $request->file('icon')->isValid()) {
$icon = uniqid();
$request->icon->storeAs(public_path('icon'), $icon . '.jpg');
$step->icon = $icon;
}
return redirect('/users/' . $user->id);
}
and blamo - it should be stored in the public_path / icon