Skip to content

Conversation

@mirzazeyrek
Copy link

Thank you for the great work on the package!

I have integrated into an existing project and noticed a functionality we need was missing. So introducing saveVersion model for forcing to create a version without any changes.

Example use case through a migration:


<?php

use App\Models\CustomerDocument;
use Illuminate\Database\Migrations\Migration;

class CreateVersionsForDocuments extends Migration
{
    public const REASON = 'MIGRATION';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $customerDocuments = CustomerDocument::all();
        foreach($customerDocuments as $customerDocument) {
            if(!$customerDocument->currentVersion()) {
                $customerDocument->setReasonAttribute(self::REASON);
                $customerDocument->saveVersion();
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant