eloquent-driver
eloquent-driver copied to clipboard
Problem with entries coming from a seeder
Everything works fine with the CP where you can add/edit entries. In the front index and show works fine. Single taxonomy pages are also working as normal.
Than you insert 1000 entries through a seeder.
$news = new Entry();
$news->site = 'default';
$news->published = 1;
$news->status = 'published';
$news->slug = $slug;
$news->uri = 'news/' . $slug;
$news->collection = 'news';
$news->data = $data;
$news->created_at = \Carbon\Carbon::now();
$news->save();
$data
and the other variables are working just fine and you end up with the following code in the DB:
id: 10 (incremental), site: 'default', origin_id: null, published: 1, status: 'published', slug: 'porro-eveniet-ipsam-tempora-et', uri: 'news/porro-eveniet-ipsam-tempora-et', date: null, collection: 'news', data: {"tags": ["clothes", "games", "space"], "title": "Porro eveniet ipsam tempora et.", "author": 1, "content": "Itaque quos qui sint..", "gallery": [], "pub_date": "2019-03-09", "updated_at": 1607932935, "updated_by": 1, "featured_image": null, "news_categories": ["nature", "fashion"]}, created_at: '2020-12-14 09:41:53'
Absolutely the same as the entries that you create from the CP. You can see/edit/delete the seeder ones normally. But in the front the Show page gives Not Found. In the taxonomy pages (/news/tags/nature) {{ tags }} lists only the CP created entries. The problem is fixed if you edit and save a seeder entry in the CP.
If you follow the code chain of the Not Found error you get to
Statamic/cms/sc/Stache/Repositories/EntryRepository.php findByUri() function
If you dd() the following for the seeder entry you get NULL and for a normal CP entry - Statamic\Eloquent\Entries\Entry:
$entry = $this->query()
->where('uri', $uri)
->where('site', $site)
->first();
I have the users in the database and I use incremented ID for entries, following the instructions in the Eloquent package.
We fill in the DB manually to (via a db import) and don't have issues so something else must be going on...
Difference I see is that I don't see the blueprint in there, wonder if that matters. I added that to this driver in a PR, maybe you need to update and add that column @lutory ?
Is this still an issue for you @lutory?
Closing due to lack of activity. If its still an issue, please re-open.