[Beta] Nested file paths #96
ryangjchandler
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've got a WIP pull request (#95) that adds basic support for nested file paths / custom path patterns for your Orbit-powered models.
I'm looking for people who use Orbit to test out this branch and find any bugs. All of the tests are still passing, without any changes (only introduced new tests) so I'm hoping that apps should work as before.
The custom file path support is purely for organisational purposes right now. It would have been quite difficult to introduce data-resolving file paths without breaking changes, i.e. using parts of the file path to resolve the column values for your models.
That will likely be something I introduce in v2.x of Orbit as I'll be able to make more drastic changes.
Reply below if you can help test and if you find any problems!
Testing the PR:
You should update the version of
ryangjchandler/orbit
in yourcomposer.json
file from^1.0
todev-feature/nested-files
and runcomposer update
in your project.There are some instructions in the PR on how it all works. The
getOrbitPathPattern
method is used to define the pattern, by default it returnsnull
. You should return astring
similar to how Laravel's route definitions work.The
{}
patterns work like so:You can specify a column name on it's own and the file path that Orbit writes to will just insert the column's value, i.e.
{slug}
will write to a file path something likecontent/model/your-slug-here/1.md
.If you would like to use a
datetime
field in your file path, you can specify a custom format for theCarbon
instance.{published_at:Y-m-d}
would take theCarbon
instance returned by$model->published_at
and format it using theY-m-d
format and insert that into the file path. This will only work if the property has adatetime
ordate
cast in the model!Beta Was this translation helpful? Give feedback.
All reactions