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/banners / libs / Schemas / Banners.php
Size: Mime:
<?php 

namespace Evsmash\Banners\Schemas;

use Evsmash\Core\Schemas\Base;

use Evsmash\Settings\TranslationConfig as Translation;

class Banners extends Base {

	protected $table = 'banners';

	// validate
	static public function validate() {

		return [
			'banner' => 'max:200', 
			'name' => 'max:100',
			'link' => 'max:200', 
			'description' => 'max:2000', 
			'sort' => 'int',
			'external' => 'int',
			'published' => 'int',
			'start' => 'datetime',
			'end' => 'datetime',
			'group_id' => 'int',
			'lang' => 'max:2',
			'clicks' => 'int'
		];

	}

	// translation
	static public function translation() {

		$config = new Translation;
		$config->set('description')->form('tinymce');
		return $config;

	}

	// create
	public function create() {

		$this->schemaCreate(function($m) {
			$m->increments('id');
			$m->string('banner', 200);
			$m->string('link', 200);
			$m->string('description', 1000);
			$m->integer('sort');
			$m->integer('external');
			$m->integer('published');
			$m->nullabletimestamps();
			$m->softDeletes();
			$m->integer('group_id');
		});

	}

	// rebuild_1
	public function rebuild_1() {

		$this->schemaDrop('views');

	}

	// rebuild_2
	public function rebuild_2() {

		$this->schemaAdd('name', function($m) {
			$m->string('name', 100)->after('id');
		});

	}

	// rebuild 3
	public function rebuild_3() {

		$this->schemaModify('link', 'VARCHAR(200)');

	}

	// rebuild 4
	public function rebuild_4() {

		$this->schemaAdd('clicks', function($m) {
			$m->integer('clicks')->after('group_id');
		});

	}

	// rebuild 5
	public function rebuild_5() {

		$this->schemaModify('description', 'VARCHAR(2000)');

	}

	// rebuild 6
	public function rebuild_6() {

		$this->schemaAdd('language', function($m) {
			$m->string('language', 2)->after('group_id');
		});

	}

	// rebuild 7
	public function rebuild_7() {

		$this->schemaAdd('start', function($m) {
			$m->datetime('start')->nullable()->after('published');
		});
		$this->schemaAdd('end', function($m) {
			$m->datetime('end')->nullable()->after('start');
		});

	}

}