Skip to content

Version 2.2.14

Choose a tag to compare

@wimurk wimurk released this 16 Dec 10:34
· 19 commits to main since this release

Full Changelog: 2.2.13...2.2.14

Added

  • SkipApiGeneration Attribute: New functionality to gain granular control over which relationships are included in API generation.

  • Using the #[SkipApiGeneration] attribute, you can ignore specific relationships.

  • Supports scopes to selectively ignore relationships for actions, requests, or resource (or all at once).

  • Example: #[SkipApiGeneration([SkipApiGeneration::ACTIONS])] above a relationship method ensures it is not updateable but still visible in the Resource.

  • Smart Relation Detection: The generator now supports all standard Eloquent relations and automatically distinguishes between "Single" relations (returning an object, such as HasOne, BelongsTo, HasOneThrough) and "Collection" relations (returning an array/collection, such as HasMany, BelongsToMany).

  • Newly supported relations: MorphOne, MorphTo, HasOneThrough, MorphMany, HasManyThrough, MorphedByMany.

Advanced CLI Options:

  • --force: Overwrite existing files without confirmation.

  • --only: Generate only specific parts (controller, actions, requests, or resource).

  • --except: Exclude specific parts from generation.

  • Improved Resource Generation: Resources are now correctly wrapped: new UserResource(...) for single relations and UserResource::collection(...) for collections.

  • Strict Typing: MakeApiResource now uses strict types (declare(strict_types=1);).

  • Route Suggestion: After successful generation, the correct Route::apiResource line is displayed directly in the console.

Improved

  • MorphedByMany Fix: MorphedByMany relations are now correctly recognized as pivot relations and no longer mistakenly treated as HasMany (due to stricter in_array checks instead of startsWith).
  • Validation Logic: Validation rules for requests have been tightened. For "Single" relations, validation is now correctly applied to relation.field instead of relation.*.field.
  • UX Improvements:
  • The interaction when overwriting directories (such as Actions and Requests) has been improved: you are now asked once whether to overwrite the entire directory instead of per file.
  • Clearer console output with step-by-step status messages.

Bugfixes:

  • Fixed: Double prompts when overwriting directories.
  • Fixed: Error when selecting from multiple Resources (returned path instead of namespace).
  • Fixed: Crash when getClassName failed on unknown relations.