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

namespace Evsmash\Items\Schemas;

use Evsmash\Core\Schemas\Base;

use Evsmash\Settings\TranslationConfig as Translation;

class Items extends Base {

	protected $table = 'items';

	// validate
	static public function validate() {

		return [
			'name' => 'req|max:100', 
			'slug' => 'req|max:100', 
			'content' => 'max:100000', 
			'content_extra' => 'max:100000', 
			'sneak' => 'max:1000', 
			'photo' => 'max:200', 
			'price' => 'float',
			'price_old' => 'float',
			'currency' => 'max:3',
			'sort' => 'int',
			'news' => 'int',
			'promoted' => 'int',
			'published' => 'int',
			'type_id' => 'int'
		];

	}

	// translation
	static public function translation() {

		$config = new Translation;
		$config->set('name');
		$config->set('price');
		$config->set('content')->form('tinymce');
		$config->set('content_extra')->form('tinymce');
		$config->set('sneak')->form('textarea');
		return $config;

	}

	// create
	public function create() {

		$this->schemaCreate(function($m) {
			$m->increments('id');
			$m->string('name', 100);
			$m->string('slug', 100);
			$m->text('content');
			$m->string('sneak', 1000);
			$m->string('photo', 200);
			$m->tinyInteger('published');
			$m->nullabletimestamps();
			$m->softDeletes();
			$m->integer('type_id');
			$m->integer('views');
		});

	}

	// rebuild 1
	public function rebuild_1() {

		$this->schemaAdd('price', function($m) {
			$m->decimal('price', 9, 2)->after('photo');
		});

	}

	// rebuild_2
	public function rebuild_2() {

		$this->schemaAdd('sort', function($m) {
			$m->integer('sort')->after('price');
		});
		$this->schemaAdd('promoted', function($m) {
			$m->integer('promoted')->after('sort');
		});

	}

	// rebuild 3
	public function rebuild_3() {

		$this->schemaAdd('content_extra', function($m) {
			$m->text('content_extra')->after('content');
		});

	}

	// rebuild 4
	public function rebuild_4() {

		$this->schemaAdd('price_old', function($m) {
			$m->decimal('price_old', 9, 2)->nullable()->after('price');
		});

	}

	// rebuild 5
	public function rebuild_5() {

		$this->schemaAdd('currency', function($m) {
			$m->string('currency', 3)->nullable()->after('price_old');
		});

	}
	// rebuild 6
	public function rebuild_6() {

		$this->schemaAdd('new', function($m) {
			$m->tinyInteger('new')->after('sort');
		});

	}

}