/** * Run the migrations. * * @return void */ public function up() { Schema::create('nodes', function (Blueprint $table) { $table->increments('id'); $table->integer('node_type_id')->unsigned(); $table->integer('user_id')->unsigned(); NestedSet::columns($table); $table->boolean('mailing')->default(0); $table->boolean('visible')->default(1); $table->boolean('sterile')->default(0); $table->boolean('home')->default(0); $table->boolean('locked')->default(0); $table->integer('status')->default(30); $table->boolean('hides_children')->default(0); $table->double('priority')->unsigned()->default(1); $table->timestamp('published_at')->nullable(); $table->string('children_order')->default('_lft'); $table->string('children_order_direction', 4)->default('asc'); $table->enum('children_display_mode', ['tree', 'list'])->default('list'); $table->timestamps(); $table->index('mailing'); $table->index('home'); $table->index('node_type_id'); $table->foreign('node_type_id')->references('id')->on('node_types')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users'); }); }
/** * DescendantsRelation constructor. * * @param QueryBuilder $builder * @param Model $model */ public function __construct(QueryBuilder $builder, Model $model) { if (!NestedSet::isNode($model)) { throw new InvalidArgumentException('Model must be node.'); } parent::__construct($builder, $model); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('name'); \Kalnoy\Nestedset\NestedSet::columns($table); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('image'); NestedSet::columns($table); $table->timestamps(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->text('description')->nullable(); $table->string('slug'); NestedSet::columns($table); $table->timestamps(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('description'); $table->string('icon'); \Kalnoy\Nestedset\NestedSet::columns($table); $table->timestamps(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('prso_categories', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('slug')->nullable(); $table->text('desc')->nullable(); NestedSet::columns($table); $table->timestamps(); $table->index(['_lft', '_rgt', 'parent_id', 'slug']); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('structure', function (Blueprint $table) { $table->increments('id'); $table->boolean('published')->default(true); $table->integer('position')->unsigned(); $table->string('alias'); Nestedset\NestedSet::columns($table); $table->string('controller'); $table->timestamps(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('slug')->unique(); $table->boolean('is_main')->default(0); $table->timestamps(); $table->softDeletes(); NestedSet::columns($table); }); }
public static function setUpBeforeClass() { $schema = Capsule::schema(); $schema->dropIfExists('categories'); $schema->create('categories', function (\Illuminate\Database\Schema\Blueprint $table) { $table->increments('id'); $table->string('name'); $table->softDeletes(); NestedSet::columns($table); }); Capsule::enableQueryLog(); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('article_categories', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('type'); $table->string('keywords'); $table->string('description'); \Kalnoy\Nestedset\NestedSet::columns($table); $table->timestamps(); }); }
public function up() { Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('title')->nullable(); $table->text('body'); $table->morphs('commentable'); $table->morphs('creator'); NestedSet::columns($table); $table->timestamps(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('permissions', function (Blueprint $table) { $table->increments('id'); NestedSet::columns($table); $table->string('name'); $table->enum('type', ['directory', 'resource', 'permission'])->default('directory'); $table->string('icon')->nullable(); $table->string('as')->nullable(); $table->string('uses')->nullable(); $table->timestamps(); }); }
public static function setUpBeforeClass() { $schema = Capsule::schema(); $schema->dropIfExists('menu_items'); Capsule::disableQueryLog(); $schema->create('menu_items', function (\Illuminate\Database\Schema\Blueprint $table) { $table->increments('id'); $table->unsignedInteger('menu_id'); $table->string('title')->nullable(); NestedSet::columns($table); }); Capsule::enableQueryLog(); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('peoples', function (Blueprint $peoples) { $peoples->increments('id'); $peoples->string('name', 25); $peoples->string('surname', 25); $peoples->integer('age')->unsigned(); $peoples->enum('gender', ['male', 'female']); $peoples->integer('spouse')->nullable()->unsigned(); $peoples->foreign('spouse')->references('id')->on('peoples'); NestedSet::columns($peoples); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('menu__menus', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('url')->nullable(); $table->string('attribute_target')->nullable(); $table->string('attribute_id')->nullable(); $table->string('attribute_class')->nullable(); $table->boolean('active')->default(false); $table->boolean('useSubject')->default(false); $table->integer('subject_id')->nullable()->index(); $table->string('subject_type')->nullable()->index(); NestedSet::columns($table); $table->timestamps(); $table->engine = 'InnoDB'; }); }
/** * @param mixed $root * * @return int */ protected function getRootNodeId($root = false) { if (NestedSet::isNode($root)) { return $root->getKey(); } if ($root !== false) { return $root; } // If root node is not specified we take parent id of node with // least lft value as root node id. $leastValue = null; /** @var Model|NodeTrait $node */ foreach ($this->items as $node) { if ($leastValue === null || $node->getLft() < $leastValue) { $leastValue = $node->getLft(); $root = $node->getParentId(); } } return $root; }
public function up() { Schema::create('categories', function ($table) { $table->increments('id')->unsigned(); NestedSet::columns($table); // вместо NestedSet::columns($table); можно использовать 3 такие столбца // $table->unsignedInteger('_lft'); // $table->unsignedInteger('_rgt'); // $table->tinyInteger('parent_id')->unsigned()->nullable(); $table->tinyInteger('level')->unsigned(); $table->string('type', 20); $table->string('menutype', 20); $table->string('title', 100); $table->string('sef', 50)->nullable(); $table->string('class', 50); $table->text('body')->nullable(); $table->string('image', 255)->nullable(); $table->string('metatitle', 255)->nullable(); $table->string('metakey', 255)->nullable(); $table->string('metadesc', 255)->nullable(); }); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('categories', function (Blueprint $table) { $table->increments('id'); $table->string('name', 30); $table->string('name_ru', 30); $table->softDeletes(); NestedSet::columns($table); }); Schema::create('products', function (Blueprint $table) { $table->increments('id'); $table->string('model', 15)->unique(); $table->string('article', 15)->nullable(); $table->integer('category_id')->unsigned(); $table->string('growth')->nullable(); $table->string('size')->nullable(); $table->text('description')->nullable(); $table->boolean('new')->default(0); $table->boolean('published')->default(0); $table->string('photo')->nullable(); $table->timestamps(); $table->foreign('category_id')->references('id')->on('categories')->uonUpdate('cascade'); }); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('library_categories'); NestedSet::dropColumns($table); }
/** * Reverse the migrations. * * @return void */ public function down() { NestedSet::dropColumns($table); Schema::drop('ticket_departments'); }
/** * @param $id * @param $operator * @param $boolean * * @return $this */ protected function whereIsBeforeOrAfter($id, $operator, $boolean) { if (NestedSet::isNode($id)) { $value = '?'; $this->query->addBinding($id->getLft()); } else { $valueQuery = $this->model->newQuery()->toBase()->select('_n.' . $this->model->getLftName())->from($this->model->getTable() . ' as _n')->where('_n.' . $this->model->getKeyName(), '=', $id); $this->query->mergeBindings($valueQuery); $value = '(' . $valueQuery->toSql() . ')'; } list($lft, ) = $this->wrappedColumns(); $this->query->whereRaw("{$lft} {$operator} {$value}", [], $boolean); return $this; }
/** * Reverse the migrations. */ public function down() { Schema::drop('comments'); NestedSet::dropColumns('comments'); }