PHP code example of ervinne / nw-cms-version

1. Go to this page and download the library: Download ervinne/nw-cms-version 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/ */

    

ervinne / nw-cms-version example snippets


    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        Ervinne\CMSVersion\Commands\GenerateCMSVersionMigrations::class
    ];

    'models' => [
        [
            'table'                => 'my_table',
            'primary_key'          => 'id',
            'classpath'            => \App\User::class,
            'is_published_field'   => 'my_is_published_field',
            'is_published_value'   => true,
            'is_unpublished_value' => false,
        ],
    ],

    ...
    use Ervinne\CMSVersion\VersionControlled;

    class BannerSet extends Model
    {
        use VersionControlled;
    ...

    CMSVersion::insert([
        'display_name' => 'Default',
        'description' => 'Default Version',
        'status' => 'Published'
    ]);

    $bannerSet               = new BannerSet();
    $bannerSet->version_id   = $request->version_id; // assumes the version comes from the request
    $bannerSet->label        = $request->label;
    $bannerSet->images_json  = $request->banners;
    $bannerSet->is_published = $request->is_published;
    $bannerSet->saveWithVersion();
`
    $ php artisan vendor:publish --provider="Ervinne\CMSVersion\Providers\CMSVersionServiceProvider"
`
    $ php artisan make:cmsvmigration
`
    $ php artisan migrate