condition makes this work, needs more testing

This commit is contained in:
spencerrlongg 2024-02-07 20:03:37 -06:00
parent 43d8474caa
commit bcfa913450
2 changed files with 7 additions and 4 deletions

View file

@ -11,6 +11,7 @@ use App\Models\User;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Redirect; use Redirect;
@ -513,9 +514,8 @@ class AssetModelsController extends Controller
$validator = Validator::make($data, $rules); $validator = Validator::make($data, $rules);
// Okay, this is the problem. Seems to be failing every time, kind of makes sense because it looks like
// $rules is an empty array, but I need to wrap my head around this entire method a little more.
if($validator->fails()){ if($validator->fails()){
Log::debug($validator->errors());
return false; return false;
} }

View file

@ -92,8 +92,11 @@ class CustomFieldset extends Model
array_push($rule, $field->attributes['format']); array_push($rule, $field->attributes['format']);
$rules[$field->db_column_name()] = $rule; $rules[$field->db_column_name()] = $rule;
//add not_array to rules for all fields // add not_array to rules for all fields
$rules[$field->db_column_name()][] = 'not_array'; // condition added to fix issue with model default updates
if ($field->element != 'checkbox') {
$rules[$field->db_column_name()][] = 'not_array';
}
} }
return $rules; return $rules;