Skip to content

Instantly share code, notes, and snippets.

@NemoD503
Last active August 29, 2015 14:09
Show Gist options
  • Save NemoD503/d9949ac51ca0905d90a6 to your computer and use it in GitHub Desktop.
Save NemoD503/d9949ac51ca0905d90a6 to your computer and use it in GitHub Desktop.
# ===================================
# Form Field Definitions
# ===================================
fields:
title:
label: Название программы
span: left
price:
label: Цена
type: number
span: right
test:
label: '123'
type: relation
nameFrom: fio
Reviews:
label: Reviews
type: relation
nameFrom: fio
use Model;
/**
* Program Model
*/
class Program extends Model
{
/*.........*/
public $morphMany = [
'Reviews' => ['Cbs\School\Models\Review', 'name' => 'attachable'],
];
/*.......*/
}
/**
* review Model
*/
class Review extends Model
{
public $morphTo = [
'attachable' => []
];
}
class CreateProgramsTable extends Migration
{
public function up()
{
Schema::create('cbs_school_programs', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('title');
$table->string('description')->nullable();
$table->float('price')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('cbs_school_programs');
}
}
class CreateReviewsTable extends Migration
{
public function up()
{
Schema::create('cbs_school_reviews', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('fio');
$table->integer('account_id');
$table->string('company')->nullable();
$table->string('position')->nullable();
$table->text('text');
$table->date('date')->nullable();
$table->integer('sort')->default('500');
$table->boolean('published')->default('0');
$table->morphs('attachable');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('cbs_school_reviews');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment