I have a combo box with data from model. Now I want to save value from this combo box into my database. when I save it returns the following error message:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'type' cannot be null.
Data from this model returns combobox
class TypeProperties extends Model
{
protected $table = 'type_properties';
public static $types = [
'textbox' => 'Textbox',
'textarea' => 'Textarea',
];
}
Combobox:
<select name="properties" class="form-control" name="type">
@foreach($asset as $key =>$value)
<option value="{{$key}}">
{{$value}}
</option>
@endforeach
</select>
Function save:
function addPro(Request $req){
$id = $req->type_id;
$type = AssetType::find($id);
$pro = new TypeProperties;
$pro->name = $req->name;
$pro->code = $req->code;
$pro->type = $req->type;
$pro->assettype_id = $req->type_id;
$pro->save();
return redirect(url($type->id.'/add/property'))->with('message','Save successful');
}