Closed jessealkema closed 2 years ago
We maintain our own internal modules through packages and handle table prefixes through a base model in the module. It seems that the eloquent function getTable
is called to retrieve the generated name. To fix this problem for now I've added laravel_
to the prefix checker.
<?php
namespace Noardcode\Compass\Financial\Models;
use Illuminate\Support\Str;
/**
* Financial base model.
*/
abstract class Model extends \Noardcode\Compass\Core\Models\Model
{
public function getTable()
{
if (Str::startsWith($this->table, ['fin_', 'laravel_'])) {
return $this->table;
}
return 'fin_' . ($this->table ?? Str::snake(Str::pluralStudly(class_basename($this))));
}
}
Heya, thanks for reporting.
We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as separate commits on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
laravel new bug-report --github="--public"
Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.
Thanks!
I'll re-open once you provided a repo. Thanks
Description:
When making use of eloquent models with a parent reference to itself eloquent automatically makes a customized table name. If the model uses the soft deletes trait the check on the deleted_at column should take place with the custom table name. But the prefix is added to the custom table name.
In short, custom generated name is
laravel_reserved_0
, when checking fordeleted_at
the generated name isfin_laravel_reserved_0
.Steps To Reproduce: