Comments (8)
Thanks for doing some digging!
Runway's RunwayRoutes
trait contains a slug()
method (which is required by Statamic's routing contracts).
The slug
method attempts to get the current slug for the model, using Eloquent's getAttribute
method. Since, it can't find a value for slug
on the model, it finds that there's a slug()
method on the model and tries to use that instead. That's where the infinite loop happens.
We do need the slug
method in the RunwayRoutes
method or the feature wouldn't work at all. However, it obviously needs to be re-worked to avoid the infinite loop. I'll have a think about the best way to fix this 🤔
from runway.
Are you using the {{ nocache }}
tag anywhere?
from runway.
No, I'm not using any {{ nocache }}
tag.
I'm using Laravel Herd and installed with the statamic/cli
a fresh new Statamic project. The only installed Addon is statamic-rad-pack/runway
.
Without configurating anything I've created a new Model with only these lines of code:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use StatamicRadPack\Runway\Routing\Traits\RunwayRoutes;
use StatamicRadPack\Runway\Traits\HasRunwayResource;
class Dog extends Model {
use HasRunwayResource, RunwayRoutes;
}
The runway
configuration has only one resource:
<?php
return [
'resources' => [
App\Models\Dog::class => [
'name' => 'Dogs',
'route' => '/dogs/{{ slug }}',
'template' => 'dogs/show',
],
],
'disable_migrations' => true,
];
I open Tinker straight after that:
After I've removed the RunwayRoutes
trait, I'm getting a null
as expected:
from runway.
What does your migration look like? Do you have a slug
column?
from runway.
In my real project I do have a slug column
, but here in my example with the freshly created Statamic project and the Dog
class, there is no migration. But in both cases I'm getting the exception.
from runway.
Do you get the same error when creating models with the Dog::create([])
syntax?
from runway.
If I try to create the Dog
model with Dog::create([])
then I get a different error:
I've tested it now with Laravel Sail, to check if Laravel Herd is the problem. But the same exception 😞
It's really strange. Especially as it's a completely fresh Statamic installation.
from runway.
After some tests I found out that the exception only occurs if the slug
is unset. If it has a value, everything's fine.
In my case the user has the possibility to set the slug manually. If it's not set, in the life cycle event creating
the value is generated by another field, e.g. title
.
But the content of the slug
field cannot be checked, because if it's empty, the exception is thrown.
I have to use this workaround: Get all attributes with toArray()
or getAttributes()
and check if the slug is set 🙃
from runway.
Related Issues (20)
- Augmentation N+1 query issue on frontend HOT 5
- Upgrade created empty blueprints HOT 3
- Listing models is slow HOT 7
- Has Many relationship seems to have broke from v5 -> v6 HOT 11
- Resource listing sort order is not applied correctly HOT 1
- Accessing a runway model from a non-runway collection HOT 2
- User column view preferences interfere with Runway finding custom primaryKey HOT 4
- Generated blueprint error on Float values
- Empty response for Assets on entry view route HOT 2
- Not compatible with statamic/eloquent-driver HOT 1
- N+1 queries in ResourceActionController HOT 1
- Model accessors shouldn't be orderable in listing table
- CP Nav Item outside of Content Section when using Translations
- Related resource property does not recognize underscore in handle name HOT 2
- Related resource stack doesn't close when saved HOT 1
- Problems with `user_roles` & `user_groups` fieldtypes HOT 3
- FR: Enable resources to have revisions HOT 1
- STI broken by reference-passing PR HOT 3
- Setting blueprint Allow Creating to false does not edit blueprint. HOT 1
- HasManyFieldtype still running sync() when read_only is set HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runway.