By Entires, do you mean Integers ? Which integers are null ? $Location_ID ?
Livewire - Entires into database are NULL
I was able to insert data into the database normally. However, when I tried to implement validation on the form, any and all new entries into the database are now NULL. What's strange is that the validation works, and there even is a success message if everything checks out. I do not understand why all the entries are null.
Here is my code:
// List of all variables in data
public $Date, $Visible_Public, $Start_8AM, $DHS_Certified, $In_Person, $IL_Class, $Instructor_First_Name, $Location_Name, $Max_Students, $Location_ID, $Course_Name, $Instructor, $Location;
public function store(Request $request) {
$validatedData = $this->validate([ 'Visible_Public' => 'required', 'Start_8AM' => 'required', 'DHS_Certified' => 'required', 'In_Person' => 'required', 'IL_Class' => 'required', 'Location_Name' => 'required', 'Max_Students' => 'required', 'Course_Name' => 'required', 'Date' => 'required', ]);
Class_Date_BitmappModel::create($request->only([
'Visible_Public', 'Start_8AM', 'DHS_Certified', 'In_Person'
]));
Class_LocationModel::create($request->only([
'Location_Name', 'Max_Students'
]));
Class_DateModel::create($request->only([
'Date' => 'required'
]));
InstructorModel::create($request->only([
'Instructor_First_Name'
]));
CourseModel::create($request->only([
'Course_Name'
]));
session()->flash('message', 'Post made successfully');
}
Here is an example of one of my input forms:
<div class="absolute right-25 md:w-2/3">
<input wire:model="Start_8AM" id="Start8" type="radio" value='true' class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
<label name="Start_8AM" for="Start_8AM">Yes</label>
<input wire:model="Start_8AM" id="Start8" type="radio" value='false' class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
<label for="Start_8AM">No</label>
@error('Start_8AM') <span class="text-red-600/100 error">{{ $message }}</span>@enderror
</div>
@Jdubstep1357 Yes that's right, but first you validate all datas and then you create the models with the needed datas.
The $validatedData variable contains all the validated datas.
Please or to participate in this conversation.