Slug vs ID in Databases

I got quite far in utilizing Kirby to edit a database in panels.

How do you ideally deal with existing data that is relying on IDs instead of Slugs?

I understand that in order to create a new record (file or database), a new slug has to be created (as identifier on the filesystem). Since the database is wrapped around the file based way of creating data this is true for adding a new record to a database as well, but it’s quite awkward.

To make the backend work with legacy data without slugs, I use the ID as slug until they have one:

	public function children()
	{
		$data = [];

		foreach (Db::select('partner') as $i => $partner) {
			$data[] = [
				'slug'     => $partner->slug() ?? $partner->id() ,
				// ...
				'content' => []
		}
	}

That kind of works, but it’s weird.

How do you, who implemented databases in panels, deal with this?
Are there better ways than overwriting all these Pagemethods like changeStatusToDraft() for every model? (Plugins?)

Last question: i it annoying that people ask for something that Kirby wasn’t intended for in the first place? ^^

As long as you use something unique, it doesn’t really matter what you use for the slug. But yes, to modify this, you need a model and ideally the plugin that circumvents the slug field in the page create dialog that you already found.

It is quite normal that people go beyond the perceived limits of a system, so all fine.

But using a database instead of the file system does indeed require some work and cannot that easily be automated I guess, because you have to take data types into account when using a database, so you definitely need a data model.

Thanks for confirming my observation!