K
K
Konstantin2019-03-08 03:15:13
Laravel
Konstantin, 2019-03-08 03:15:13

Why doesn't ::create add an entry to the database?

I don't get any exceptions or errors.

$r = [
                "lastname" => "Huseyn",
                "firstname" => "Fit",
                "middlename" => "Akif",
                "birthday" => "1981-04-09",
                "company" => "XXX",
                "document_number" => '16428285',
                "pincode" => "QT0FE12",
                "code" => '19283',
                "idEvent" => 17,
                "status" => 1
            ];

            $c = \App\Visitor::create($r);

If doing dd($c);gives the complete model
The model itself:
public $timestamps = false;

    public $table = 'visitors';

    protected $fillable = [
        "lastname",
        "firstname",
        "middlename",
        "birthday",
        "company",
        "document_number",
        "pincode",
        "code",
        "idEvent"
    ];

    protected $primaryKey = 'idVisitor';

Dump tables:
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;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question