简体   繁体   中英

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.

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. I am going to close this and open a new question that is more relevant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM