Im a laravel beginner, also my first time to use a framework i just learned laravel for 5 days,so i don't understand much about this framework, im using the latest laravel 8 i have a problem with my project, when trying to validate the data from the form.
i dont know this method is working or not (Probably not)
$request->validate([ 'name' => 'required', 'icons' => 'required', ]);when i trying to get the error message {{$error}} , only showing [] in my view.
<form action="{{ route('poseicon.store') }}" method="post" enctype="multipart/form-data">
@csrf
<div class="display">
<label>name:</label>
<input type="text" name="name" id="name">
<label>icons:</label>
<input type="file" name="icons" id="icons" class="">
{{$errors}}
<input type="submit" value="submit">
</div>
</form>
this is my controller
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'icons' => 'required',
]);
//this working correctly when validate method above deleted
$file = $request->file('icons');
$filename = 'pose-photo-' . time() . '.' . $file->getClientOriginalExtension();
$path = $file->storeAs('img', $filename);
//this also working correctly when validate method above deleted
Poseicon::create([
'name' => $request->name,
'icons' => $filename
]);
return redirect('/poseicon');
}
i already try all the documentation said but still not working