#Create method is not attaching an attribute
8 messages · Page 1 of 1 (latest)
This is the dd of the request
And this is the error that keeps popping up.
public function store(StoreStudentRequest $request)
{
// dd($request->validated());
Student::create($request->validated());
return redirect()->route('students.index')->with('success', 'Student created successfully!');
}```
This is the controller method
And this is the StudentRequest.php
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'max:255'],
'class_id' => ['required', 'exists:classes,id'],
'section_id' => ['required', 'exists:sections,id'],
];
}```
The data is being passed from Vue, can be seen in the controller dump, but the attribute is not going through the query
https://laravel.com/docs/11.x/eloquent#mass-assignment
If you are using fillable on your model, be sure you have all columns you want to allow