Hi @viper75x
Please share the code of $this->validateInvMaterial()
Also, what do you get if you do a
dd($item);
right before the $item->save()?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
L8, with Blade
{
// InvMaterial::create($this->validateInvMaterial());
// dd(request()->all());
$item = new InvMaterial($this->validateInvMaterial());
$item->category_id = 2;
$item->classification_id = 4;
$item->save();
return redirect(route('items.index'));
}
I set the category and classification as those were the first null value errors I received. Then it kept going.
the dd returns:
array:7 [▼
"_token" => "DBMp5l2tSCEEzidnIOJdf5Hgw3IhVN5rnpE6A7Fy"
"catalogNumber" => "123456"
"description" => "asdf"
"short" => "asdkjf"
"classification" => "2"
"category" => "4"
"stocked" => "1"
]
so, nothing is null. The current null error is on the catalogNumber.
All six fields are fillable. As you can see, there are two FKs, category_id and classification_id.
The 'short' field is the only nullable.
There are three other boolean fields in the table, not included in the form, that are NOT nullable, but the default, via the migration, is set to true or false...hm, I'm wondering if this might cause a problem?
Thoughts?
Also, I could use some tips on formatting my posts, as I see most everyone else has these nice colored code wrappers... Hmm, I moved those backquotes? around and got a better looking post
Update: I've added the other fields and set their values in the store function as well, but the error remains.
Below is the code specific to this field.
<div class="field col-sm-8">
<label class="label" for="catalogNumber">Catalog Number</label>
<div class="control">
<input type="text" class="input form-control @error('catalogNumber')" name="catalogNumber" id="catalogNumber" value="">
@error('catalogNumber')
<p class="help is-warning">{{ $errors->first('catalogNumber') }}</p>
@enderror
</div>
</div>
Your $fillable array contains a typo catalogeNumber
and the model attributes does not contain anything resembling catalogueNumber (or catalogNumber)
#attributes: array:8 [▼
"description" => "asdfsda"
"short" => "asdf"
"category_id" => 2
"disc_date" => null
"reason" => null
"discontinued" => false
"inUse" => true
"classification_id" => 4
]
Please or to participate in this conversation.