PHP code example of denis-kisel / constructor

1. Go to this page and download the library: Download denis-kisel/constructor 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/ */

    

denis-kisel / constructor example snippets


Schema::create('posts', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->timestamps();
});

Schema::create('posts', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('name', 50);
    $table->text('description')->nullable();
    $table->integer('sort')->default(0);
    $table->boolean('is_active')->default(1);
    $table->timestamps();
});

// For Post
Schema::create('posts', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->integer('sort')->default('0');
    $table->boolean('is_active')->default('1');
    $table->timestamps();
});


// For PostTranslation
Schema::create('post_translations', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->integer('post_id')->unsigned();
    $table->string('locale')->index();
    $table->string('name', 50);
    $table->text('description')->nullable();
    $table->unique(['post_id','locale']);
    $table->timestamps();
});

Schema::create('pages', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('code')->nullable();
    $table->string('slug')->nullable();
    $table->string('name');
    $table->text('description')->nullable();
    $table->string('title')->nullable();
    $table->string('h1')->nullable();
    $table->text('keywords')->nullable();
    $table->text('meta_description')->nullable();
    $table->integer('sort')->default('0');
    $table->boolean('is_active')->default('1');
    $table->timestamps();
});

// Grid
protected function grid()
{
    $grid = new Grid(new Post);

    $grid->model()->orderBy('created_at', 'desc');

    $grid->id(__('admin.id'));
    $grid->name( __('admin.name'))->editable('text');
    $grid->description( __('admin.description'))->editable('text');
    $grid->sort( __('admin.sort'))->editable('text');
    $grid->is_active( __('admin.is_active'))->editable('select', ActiveHelper::editable());

    $grid->created_at(__('admin.created_at'));
    $grid->updated_at(__('admin.updated_at'));

    $grid->actions(function ($actions) {
        $actions->disableView();
    });

    return $grid;
}

// Form
protected function form()
{
    $form = new Form(new Post);

    $form->text('name', __('admin.name'))->
 bash
$ php artisan construct:model App\\Models\\Post 
 bash
$ php artisan construct:model App\\Models\\Post --fields=name:string:50,description:text{nullable},sort:integer{default:0},is_active:boolean{default:1}
 bash
$ php artisan construct:modelt App\\Models\\Post --fields=name:string:50[t],description:text{nullable}[t],sort:integer{default:0},is_active:boolean{default:1}
 bash
$ php artisan construct:page App\\Models\\Post
 bash
$ php artisan construct:admin App\\Models\\Post --fields=name:string:50,description:text{nullable},sort:integer{default:0},is_active:boolean{default:1}
 bash
$ php artisan construct:model App\\Models\\Post --fields=name:string:50[t],description:text{nullable}[t],sort:integer{default:0},is_active:boolean{default:1}