Skip to content

Conversation

@eabay
Copy link

@eabay eabay commented Jan 8, 2025

Mark the Prefix attribute as repeatable and update the ClassRouteAttributes class to support multiple prefixes.

  • Prefix Attribute:

    • Mark the Prefix attribute in src/Attributes/Prefix.php as repeatable by adding Attribute::IS_REPEATABLE.
  • ClassRouteAttributes:

    • Update the prefix method in src/ClassRouteAttributes.php to return an array of prefixes.
    • Update the groups method in src/ClassRouteAttributes.php to handle multiple prefixes.
  • Tests:

    • Add a test for multiple prefixes in tests/AttributeTests/PrefixAttributeTest.php.
    • Add multiple Prefix attributes to the PrefixTestController class in tests/TestClasses/Controllers/PrefixTestController.php.

For more details, open the Copilot Workspace session.

Mark the `Prefix` attribute as repeatable and update the `ClassRouteAttributes` class to support multiple prefixes.

* **Prefix Attribute**:
  - Mark the `Prefix` attribute in `src/Attributes/Prefix.php` as repeatable by adding `Attribute::IS_REPEATABLE`.

* **ClassRouteAttributes**:
  - Update the `prefix` method in `src/ClassRouteAttributes.php` to return an array of prefixes.
  - Update the `groups` method in `src/ClassRouteAttributes.php` to handle multiple prefixes.

* **Tests**:
  - Add a test for multiple prefixes in `tests/AttributeTests/PrefixAttributeTest.php`.
  - Add multiple `Prefix` attributes to the `PrefixTestController` class in `tests/TestClasses/Controllers/PrefixTestController.php`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/spatie/laravel-route-attributes?shareId=XXXX-XXXX-XXXX-XXXX).
@eabay eabay marked this pull request as draft January 8, 2025 14:06
@eabay
Copy link
Author

eabay commented Jan 8, 2025

I took a shot at getting this feature with the help of Copilot Workspace. It worked pretty well, although a few tests didn't pass.

Leaving it open to take another try when I have time.

* @psalm-suppress NoInterfaceProperties
*/
public function prefix(): ?string
public function prefix(): array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    public function prefixes(): array

Comment on lines +88 to +89
$prefixes = $this->prefix();
foreach ($prefixes as $prefix) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            foreach ($this->prefixes() as $prefix) {

@eabay
Copy link
Author

eabay commented Apr 16, 2025

Thanks for the reviews and improvements, @osbre!

I haven’t had a chance to revisit this, and in the meantime, I’ve found a solution to my use case using the Group attribute so I no longer need this feature.

Since it’s not something I plan to continue, I’ll go ahead and close this PR. Feel free to open a new one if you’d like to carry it forward.

Thanks again!

Sorry for making noise, @freekmurze!

@eabay eabay closed this Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants