statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 75 forks source link

Visiting a URL ending with an asterisk will throw error #242

Closed jasonvarga closed 7 months ago

jasonvarga commented 7 months ago

Visiting /* will throw an exception.

The error comes from line 46 here:

Statamic\Eloquent\Taxonomies\Taxonomy::fromModel(): Argument #1 ($model) must be of type Illuminate\Database\Eloquent\Model, array given

https://github.com/statamic/eloquent-driver/blob/a67cb95d599fcb35e13e15cb20c6243b2eb71222/src/Taxonomies/TaxonomyRepository.php#L40-L47

This is because when you provide a key ending with * to Blink, it returns an array of values.

$blink->get('key'); // Returns 'value'
$blink->get('prefix*'); // Returns an array of values whose keys start with 'prefix'

Maybe line 46 should be changed to

return $taxonomyModel instanceof Model ? ...