我检查了数据库中的修订表,它们是我试图显示历史记录的修订记录。
$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;