I try to insert array to table:
Inserting data is:
$item = [
"lastname" => "Husey"
"firstname" => "Fik"
"middlename" => "Akif"
"birthday" => "1981-04-09"
"company" => "XXX"
"document_number" => 16428285.0
"pincode" => "QT0FE12"
"code" => 19283746564923.0
"idEvent" => "17"
]
Insert into model:
Visitor::create($item);
Model Visitor is:
class Visitor extends Model
{
public $timestamps = false;
public $table = 'visitors';
public $fillable = [
'firstname',
'lastname',
'middlename',
'document_number',
'pincode',
'ckecked',
'date_cheked',
'user_checked',
'company',
'code',
'idEvent',
'date',
'birthday'
];
}
Dump SQL is:
CREATE TABLE `visitors` (
`idVisitor` int(11) NOT NULL,
`firstname` varchar(45) NOT NULL,
`lastname` varchar(45) NOT NULL,
`middlename` varchar(45) DEFAULT NULL,
`document_number` varchar(45) NOT NULL,
`pincode` varchar(10) NOT NULL,
`ckecked` int(11) DEFAULT '0',
`date_cheked` date DEFAULT NULL,
`user_checked` int(10) UNSIGNED DEFAULT NULL,
`company` varchar(100) DEFAULT NULL,
`code` varchar(100) DEFAULT NULL,
`idEvent` int(10) NOT NULL,
`status` int(11) NOT NULL DEFAULT '1',
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`birthday` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I dont get any exception or errors.
If to make the following:
$s = Visitor::create($item);
dd($s);
It returns full model data, but DB table is empty!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire