twill icon indicating copy to clipboard operation
twill copied to clipboard

[future] Improve routing

Open aksiome opened this issue 2 years ago • 0 comments

Summary

I think that the router should be reworked to allow new options (like uses) and match a bit more how resources work in laravel. The motivation for this came while developing a package where I had to manually register all routes because I needed a custom controller.

The idea is to allow both an options array and chained methods:

TwillRoutes::module('foo', ['uses' => 'foocontroller', 'only' => []])->except()->middleware()->parameters()->...

Also by not depending on resource routes and merging the resources_options array with the options array we could have more coherent urls and avoid having these 2 kind of patterns in nested modules:

  • posts/{post}/tests/{test}
  • posts/tests/duplicate/{id}

An other goal is to avoid registering useless routes. For example a singleton does not need the restore method or bulk actions.

I'm happy to work on a PR for it, I actually started one #2157 but I should not have pulled directly on 3.x without talking about it first and it's for sure something for a future update.

aksiome avatar Mar 28 '23 17:03 aksiome