[Solved] Laravel 6 – `Undefined variable: value` only error in the first time


You could grab the max ‘id’ of the table and add 1 to it without having to grab a whole record:

...
// validation

$newdevicetypeId = DeviceType::max('id') + 1;

$GetnewdevicetypeId = sprintf('DT%04d', $newdevicetypeId);

// new DeviceType
...

There is the option of having a model event that can set this particular field after the record has been created so it has its own id to use.

6

solved Laravel 6 – `Undefined variable: value` only error in the first time