Closed ozthegreat closed 3 years ago
Hi you can also just override this method:
/**
* @return string
*/
public static function nameWithoutResource(): string
{
return class_basename(static::class);
}
Yep that's what I did. Just thought I'd raise a PR to contribute back. Great software, thanks very much!!
You can contribute. Let's make a straightforward construction:
return Str::of(class_basename(static::class))->replace('Resource', '')->whenEmpty(function () {
return 'Resource';
});
Maybe this is a little illogical, but it will work without exclusions for going beyond the limits of characters. What do you think?
Looks good!
Hi
I have my own Model type called "Resource", making the Orchid-Crud class "ResourceResource". The page title doesn't show though because the nameWithoutResource class strips the word "Resource" from everywhere in the class name, not just the end. I better solution would be replacing this line: https://github.com/orchidsoftware/crud/blob/ae8c6615c48b4e5b0afd537b62f73cc03aa2b8f9/src/Resource.php#L140
with something like (assuming they always end in "Resource"):
return substr(Str::of(class_basename(static::class)), 0, -8);