Check that the array key exists before trying to seed it

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-01-03 14:45:23 -08:00
parent d187174f00
commit fa439a1928

View file

@ -218,7 +218,7 @@ class ValidationServiceProvider extends ServiceProvider
Validator::extend('is_unique_department', function ($attribute, $value, $parameters, $validator) {
$data = $validator->getData();
if ($data['location_id'] != null && $data['company_id'] != null) {
if ((array_key_exists('location_id', $data) && $data['location_id'] != null) && (array_key_exists('company_id', $data) && $data['company_id'] != null)) {
$count = Department::where('name', $data['name'])
->where('location_id', $data['location_id'])
->where('company_id', $data['company_id'])