#Create method is not attaching an attribute

8 messages · Page 1 of 1 (latest)

midnight thistle
#

I can see the value of class_id when dd-ing the request-validated, but when I try to insert the data, the class_id is not being attached

#

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

real trail