10000 Update entry URI's when collection route is changed · Issue #378 · statamic/eloquent-driver · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Update entry URI's when collection route is changed #378
92E0
Open
statamic/cms
#11150
@mthorsdal

Description

@mthorsdal

Description

I recently had to change the route of my collection, and I found that due to using eloquent-driver, all the entries of that collection became inaccessible afterwards, as the uri no longer matched the one in entries table

Perhaps a simple command will do the trick?
Claude.ai wrote this one

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Statamic\Facades\Entry;

class UpdateEntryUris extends Command
{
    protected $signature = 'statamic:update-uris';
    protected $description = 'Update entry URIs in database';

    public function handle()
    {
        $entries = Entry::query()->where('collection', 'erlebnisse')->get();
        
        foreach ($entries as $entry) {
            $entry->save(); // This will trigger URI regeneration
            $this->info("Updated URI for entry: {$entry->id()}");
        }

        $this->info('All URIs updated successfully');
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0