I have a filed for validation:
public function update(request $request, Sight $sight)
{
$validator = Validator::make($request->all(), [
'img' => 'required|image|max:3000',
...
It must be 'required',if only 'img' field in stored record is null.
Is it possible?
This is PHP, it is dynamic. We have conditionals and variables and all that fun jazz. You control the string that contains all the rules you want to use and you have the model there. Just build your string.
public function update(Request $request, Sight $sight)
{
$required = $sight->img === null ? 'required|' : '';
$validator = Validator::make($request->all(), [
'img' => $required .'image|max:30
Thats one way without getting into extending anything.