Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
evsmash/widgets / libs / Schemas / Reviews.php
Size: Mime:
<?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');

	}

}