Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front-end routing #28

Merged
merged 29 commits into from
May 15, 2021
Merged

Front-end routing #28

merged 29 commits into from
May 15, 2021

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented May 1, 2021

Description

This pull request introduces front-end routing functionality as part of Runway. Essentially, it hooks into the DataRepository, the same way entries/terms/etc do.

Eventually, we'll use this foundation to implement live previews (#23).

Example

Say you have an e-commerce store and you're storing your products in the database. You probably at some point want to display those products on their own pages. Maybe something like /products/slug-of-product.

Basically, this feature will allow you to do that. To use it, there's two things you need to do:

First, add a route to your model's configuration:

// config/runway.php

'route' => '/products/{{ slug }}',

In addition, you'll need to add the HasRoutes trait and the Responsable interface to your Eloquent model.

// app/Models/Product.php

use DoubleThreeDigital\Runway\Routing\Traits\RunwayRoutes;
use Illuminate\Contracts\Support\Responsable;

class Product extends Model implements Responsable
{
    use RunwayRoutes;

To Do

  • Don't rebind the whole DataRepository ourselves, extend on what's already there.
  • Implement a table based system for URIs
  • Add command to manually rebuild URI cache
  • Ensure variables are augmented for use in Antlers Asset field isn't being augmented properly in Antlers #32
  • Add a 'Visit' button when editing models in the Control Panel
  • Do we need the user to add the Responsable interface to their models, can we do that in our trait?
  • Ensure templates/layouts are configurable
  • Write tests
  • Write documentation

Related Issues

Closes #25.

src/Routing/Traits/RunwayRoutes.php Outdated Show resolved Hide resolved
src/Routing/Traits/RunwayRoutes.php Outdated Show resolved Hide resolved
src/Routing/Traits/RunwayRoutes.php Outdated Show resolved Hide resolved
src/Routing/ResourceResponse.php Outdated Show resolved Hide resolved
src/Routing/ResourceResponse.php Outdated Show resolved Hide resolved
@duncanmcclean duncanmcclean marked this pull request as ready for review May 15, 2021 22:23
@duncanmcclean duncanmcclean merged commit 0e3c7ad into 2.0 May 15, 2021
@duncanmcclean duncanmcclean deleted the front-end-routing branch May 15, 2021 22:25
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.

None yet

1 participant