should work fine, and there are other reasons to write null to the database such as forgetting to make the columns fillable
Simplest check is to dump $request->all() in your controller and check these values are present
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
the database columns are email, phone and the input names are admission_email, admission_phone whenever i submit the form they show as null in the database for some reason. I used to use this method to do this type of thing but it doesn't work anymore am i missing something??
<?php
namespace App\Http\Requests\Pages;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;
class AdmissionActionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
'admission_email' => 'required|email|unique:admissions,email',
'admission_phone' => 'required|numeric|digits_between:10,14',
'address' => 'required|string|max:255',
'student.*.student_name' => 'required|string|max:255',
'student.*.admission_category_id' => 'required|numeric|exists:admission_categories,id',
'student.*.class_room_id' => 'required|numeric|exists:class_rooms,id',
'student.*.gender' => 'required|string|max:255|in:male,female',
'student.*.old_grade' => 'required|numeric|min:0|max:100',
];
}
public function prepareForValidation(): void
{
$this->merge([
'email' => $this->admission_email,
'phone' => $this->admission_phone,
]);
}
}
Please or to participate in this conversation.