Repository URL to install this package:
|
Version:
3.3.1 ▾
|
<?php
namespace Evsmash\Widgets\Schemas;
use Evsmash\Core\Schemas\Base;
class Reviews extends Base {
protected $table = 'reviews';
// validate
static public function validate() {
return [
'rel' => 'req|max:50',
'ip' => 'max:15',
'author' => 'max:200',
'rate' => 'req|int',
'content' => 'req|max:10000',
'published' => 'int',
'user_id' => 'int',
'smash_id' => 'max:30',
'created_at' => 'datetime'
];
}
// create
public function create() {
if(cfg('evsmash-widgets-reviews')) {
$this->schemaCreate(function($m) {
$m->increments('id');
$m->string('rel', 50);
$m->string('ip', 15);
$m->string('author', 200);
$m->text('content');
$m->tinyInteger('published');
$m->nullabletimestamps();
$m->softDeletes();
$m->integer('user_id');
$m->string('smash_id', 30);
});
}
}
// rebuild_1
public function rebuild_1() {
if(cfg('evsmash-widgets-reviews')) {
$this->schemaAdd('rate', function($m) {
$m->tinyInteger('rate')->after('author');
});
}
}
// rebuild 2
public function rebuild_12() {
$this->schemaIndexAdd('rel');
$this->schemaIndexAdd('user_id');
$this->schemaIndexAdd('smash_id');
}
}