diff --git a/src/Exceptions/PublishedColumnMissingException.php b/src/Exceptions/PublishedColumnMissingException.php new file mode 100644 index 00000000..8f0c5a26 --- /dev/null +++ b/src/Exceptions/PublishedColumnMissingException.php @@ -0,0 +1,11 @@ +column}] publish column is missing from the {$this->table} table."); + } +} diff --git a/src/Resource.php b/src/Resource.php index 50881cb4..bbab8d55 100644 --- a/src/Resource.php +++ b/src/Resource.php @@ -10,6 +10,7 @@ use Statamic\Fields\Blueprint; use Statamic\Fields\Field; use Statamic\Statamic; +use StatamicRadPack\Runway\Exceptions\PublishedColumnMissingException; use StatamicRadPack\Runway\Fieldtypes\BelongsToFieldtype; use StatamicRadPack\Runway\Fieldtypes\HasManyFieldtype; @@ -150,9 +151,15 @@ public function publishedColumn(): ?string return null; } - return is_string($this->config->get('published')) + $column = is_string($this->config->get('published')) ? $this->config->get('published') : 'published'; + + if (! in_array($column, $this->databaseColumns())) { + throw new PublishedColumnMissingException($this->databaseTable(), $column); + } + + return $column; } /**