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 Where Exists Clauses

Метод whereExists позволяет написать SQL-условия where exists. Метод whereExists принимает в качестве аргумента замыкание, которое получит экземпляр конструктора запросов, позволяя вам определить запрос для помещения в условие "exists":

09 октября 2018 г. в Laravel

Eloquent collection groupBy Carbon

use Carbon\Carbon;
...

$projectsGroupedByYear = $projects->groupBy(function($p) {
    return Carbon::parse($p->start_year_date)->format('Y');
});