0

我检查了数据库中的修订表,它们是我试图显示历史记录的修订记录。

$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;
4

1 回答 1

0

我的 AppServiceProvider 启动方法中有一个 morphMap 设置,当可修订调用记录时会触发它,这就是为什么没有返回任何内容的原因。我将关闭它并打开一个更相关的新问题。

于 2016-03-16T17:54:39.183 回答