SQL Dump is:
CREATE TABLE `visitors` (
`idVisitor` int(11) NOT NULL,
`firstname` varchar(100) NOT NULL,
`lastname` varchar(100) NOT NULL,
`middlename` varchar(100) NOT NULL,
`document_number` varchar(100) NOT NULL,
`pincode` varchar(20) NOT NULL,
`ckecked` int(11) NOT NULL DEFAULT '0',
`date_cheked` date DEFAULT NULL,
`user_cheked` int(11) DEFAULT NULL,
`company` varchar(100) DEFAULT NULL,
`code` varchar(100) NOT NULL,
`idEvent` int(11) 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;
Full model is:
class Visitor extends Model
{
public $timestamps = false;
public $table = 'visitors';
protected $guarded = [];
protected $primaryKey = 'idVisitor';
protected static function boot()
{
parent::boot();
static::addGlobalScope(new StatusScope);
}
public function checker()
{
return $this->hasOne('App\User', 'id', 'user_checked');
}
public function event()
{
return $this->belongsTo('App\Event', 'idEvent', 'idEvent');
}
}
Insert is:
DB::table('visitors')->insert(
[
'firstname' => 'john@example.com',
'lastname' => 0, 'middlename' => '', 'document_number' => 'e', 'pincode' => '44',
'company' => '444', 'code' => '4', 'idEvent' => 17,
]
);
Also I tried:
Visitors::insert([
'firstname' => 'john@example.com',
'lastname' => 0, 'middlename' => '', 'document_number' => 'e', 'pincode' => '44',
'company' => '444', 'code' => '4', 'idEvent' => 17,
]);
So, I dont get any errors and SQL exceptions, connection with db is stable.
It just does not add data to db.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ELYThZ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire