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;
ALTER TABLE `visitors`
MODIFY `idVisitor` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
COMMIT;
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(
[
'lastname' => '1',
'firstname' => '2',
'middlename' => '2',
'birthday' => '2018-05-01',
'company' => 'dadadad',
'document_number' => 2424,
'pincode' => '444',
'code' => '4444',
'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.
The way:
Visitors::create();
Also has no effect.
I tried to list all fields in model:
protected $fillable = ['firstname', 'lastname', 'middlename', 'document_number', 'pincode', 'ckecked', 'date_cheked', 'user_cheked', 'company', 'code', 'status', 'date', 'birthday', 'idEvent'];
No effect!!! But query DELETE works
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire