PHP code example of albaroody / staging

1. Go to this page and download the library: Download albaroody/staging library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

albaroody / staging example snippets


use Albaroody\\Staging\\Traits\\Stagable;

class Patient extends Model
{
    use Stagable;
}

$patient = new Patient([
    'name' => 'John Doe',
]);

$patient->stage();

$stagedPatient = Patient::findStaged($stagingId);

// Now you can use it like a normal model
echo $stagedPatient->name;

$realPatient = $stagedPatient->promoteFromStaging();
bash
php artisan vendor:publish --tag="staging-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="staging-config"