protected function createAssignRecords(Model $model, array $keys) { $type = $model->getMorphClass(); return array_map(function ($key) use($type) { return ['role_id' => $this->getKey(), 'entity_type' => $type, 'entity_id' => $key]; }, $keys); }