Laravel. SQL server вставка записей с ID

In Connection.php line 664:

  SQLSTATE[23000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]
  Cannot insert explicit value for identity column in table 'october_test_pages' when 
  IDENTITY_INSERT is set to OFF. (SQL: insert into [october_test_pages] ([id], [type], [content]) 
  values (1, 1, {"title":"This is a simple page","content":"<h1>Hello, World<\/h1>"}))
// seed_tables
...
DB::unprepared('SET IDENTITY_INSERT october_test_pages ON');
foreach($pages as $page) {
    Page::create($page);
}
DB::unprepared('SET IDENTITY_INSERT october_test_pages OFF');
...

Похожие записи

Laravel. Catch FindOrFail Exception

use Illuminate\Database\Eloquent\ModelNotFoundException;
...
try {
  $publication = Publication::findOrFail($id);
} catch (ModelNotFoundException $ex) {
  // Error handling code
}
21 декабря 2017 г. в Laravel