0
我检查了数据库中的修订表,它们是我试图显示历史记录的修订记录。revisionHistory显示某些型号,但不是其他人
$ record-> revisionHistory虽然返回一个空数组。
其他模型的相同代码工作正常,它真的很奇怪。
这个模型代码的工作:
namespace App\Models\Slack;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes as SoftDeletes;
class Channel extends Model
{
use SoftDeletes;
use \Venturecraft\Revisionable\RevisionableTrait;
protected $revisionEnabled = true;
protected $revisionCleanup = true;
protected $historyLimit = 10;
protected $revisionCreationsEnabled = true;
这对上述模型控制器代码工作:
$channel = Channel::find($id);
return $channel->revisionHistory;
这种模式的代码无法正常工作(但也有记录在数据库中):
namespace App\Models\Organization;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes as SoftDeletes;
class Organization extends Model
{
use SoftDeletes;
use \Venturecraft\Revisionable\RevisionableTrait;
protected $revisionEnabled = true;
protected $revisionCleanup = true;
protected $historyLimit = 10;
protected $revisionCreationsEnabled = true;
上述模型的这个控制器代码显示一个空数组([]):
$organization = Organization::find($id);
return $organization->revisionHistory;
在你的第一个例子中,两行都使用'$ channel'。在第二行中,第一行使用'$ organization',第二行使用'$ organization_history'。试试'$ organization-> revisionHistory'。 – ceejayoz
感谢您的支持,但是当我举出这个例子时,这是一个错误。当我做出改变时,它仍然不起作用。 – thestepafter
尝试执行'$ organization-> revisionHistory() - > toSql()'并查看生成了哪些SQL。然后尝试直接针对SQL运行查询。 – ceejayoz