[英]revisionHistory is showing for some models but not others
I checked the revisions table in the database and their are revision records for the record I'm trying to show the history for. 我检查了数据库中的修订表,它们是我要显示其历史记录的修订记录。
$record->revisionHistory returns an empty array though. $ record-> revisionHistory返回一个空数组。
The same code for other models works fine, it is really strange. 对于其他模型,相同的代码也可以正常工作,这确实很奇怪。
This model code works: 此模型代码有效:
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;
This controller code for the above model works: 以上模型的此控制器代码有效:
$channel = Channel::find($id);
return $channel->revisionHistory;
This model code doesn't work (but there are records in the database): 该模型代码不起作用(但数据库中有记录):
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;
This controller code for the model above display an empty array ([]): 上面模型的此控制器代码显示一个空数组([]):
$organization = Organization::find($id);
return $organization->revisionHistory;
I have a morphMap setup in my AppServiceProvider boot method that is firing when revisionable calls for the record so this is why nothing is being returned. 我的AppServiceProvider引导方法中有一个morphMap设置,该记录在可修订的记录调用时会触发,因此这就是为什么未返回任何内容的原因。 I am going to close this and open a new question that is more relevant.
我将结束这一点,并提出一个更相关的新问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.