Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Console/Commands/ImportCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ private function createEloquentModel(): self
->filter(fn ($column) => in_array($column['type'], ['json', 'boolean', 'datetime', 'date', 'time', 'float', 'integer']))
->map(fn ($column) => " '{$column['name']}' => '{$column['type']}',")
->join(PHP_EOL))
->when($this->collection->requiresSlugs(), function ($str) {
return $str->replaceLast('}', <<<'PHP'

public function getRouteKeyName(): string
{
return 'slug';
}
}
PHP);
})
->__toString();

File::put(app_path("Models/{$this->modelName}.php"), $modelContents);
Expand Down
5 changes: 0 additions & 5 deletions src/Console/Commands/stubs/model-l10.stub
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,4 @@ class {{ class }} extends Model
protected $casts = [
{{ casts }}
];

public function getRouteKeyName(): string
{
return 'slug';
}
}
5 changes: 0 additions & 5 deletions src/Console/Commands/stubs/model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ class {{ class }} extends Model
{{ casts }}
];
}

public function getRouteKeyName(): string
{
return 'slug';
}
}