PHPackages                             raymondidema/category - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. raymondidema/category

ActiveLibrary[Database &amp; ORM](/categories/database)

raymondidema/category
=====================

Category table (POSTGRESQL ONLY)

1.0.1(12y ago)340MITPHPPHP &gt;=5.4.0

Since Jan 7Pushed 12y ago1 watchersCompare

[ Source](https://github.com/raymondidema/category)[ Packagist](https://packagist.org/packages/raymondidema/category)[ RSS](/packages/raymondidema-category/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Category
========

[](#category)

Category Table (Recursive) (PostgreSQL only)

Installation
------------

[](#installation)

```
 composer.json

 "require": {
	"laravel/framework": "4.1.*",
	"raymondidema/category": "dev-master"
},

```

After updating you could do `composer update` or `composer install`or alternatively `composer require raymondidema/category`

Config
------

[](#config)

```
 ./app/config/app.php

 'providers' => array( 'Raymondidema\Category\CategoryServiceProvider' );
 'aliases' => array( 'Menustructure' => 'Raymondidema\Category\Facades\Category' );

```

### Children

[](#children)

```
 Menustructure::table('categories')
                ->children($id)
                ->depth(3)
                ->get();

```

#### Optional components

[](#optional-components)

Required

table($table), children($id), childrenWithRoot($id), decendants($id), decendantsWithRoot($id), ancestors($id), breadcrumb($id), get(array('\*'))

Optional

depth($integer), where($column, $option), orderBy($column, $ascOrDesc), remember($minutes = null)

### Descendants

[](#descendants)

```
 Menustructure::table('categories')
                ->decendants($id)
                ->depth(2)
                ->where('name', 'aspire')
                ->get();

```

### Ancestors

[](#ancestors)

```
 Menustructure::table('categories')->ancestors($id)->get(array('name','slug'));

```

### Database layout example

[](#database-layout-example)

Category requires the following columns: id, parent\_id, position

```
 Schema::create('categories', function(Blueprint $table)
 	{
 		$table->increments('id');
 		$table->integer('parent_id')->unsigned()->nullable();
 		$table->string('name');
 		$table->string('slug');
 		$table->integer('position')->unsigned()->nullable();
 		$table->timestamps();
 		$table->softDeletes();
 	});

```

### How to interact with a model

[](#how-to-interact-with-a-model)

this is not required.

```
