定制 teepluss/categorize 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

teepluss/categorize

Composer 安装命令:

composer require teepluss/categorize

包简介

Laravel 4 Categorize

README 文档

README

Categorize is a category management for Laravel 4.

Installation

To get the lastest version of Theme simply require it in your composer.json file.

"teepluss/categorize": "dev-master"

You'll then need to run composer install to download it and have the autoloader updated.

Once Attach is installed you need to register the service provider with the application. Open up app/config/app.php and find the providers key.

'providers' => array(

    'Teepluss\Categorize\CategorizeServiceProvider'

)

Publish config using artisan CLI.

php artisan config:publish teepluss/categorize

Migrate tables.

php artisan migrate --package=teepluss/categorize

Usage

Creating category as a root.

$categorize = Categorize::prepare(array(
    'type'        => 'Product',
    'title'       => 'Hardware',
    'description' => 'Hardware is a ...'
));

$categorize->makeRoot();

Creating category as a child of parent.

$categorize = Categorize::prepare(array(
    'type'        => 'Product',
    'title'       => 'Hardware - CPU',
    'description' => 'CPU is a ...'
));

$parent = Categorize::getCategoryProvider()->findById(1);
// or
// $parent = Categorize::getCategoryProvider()->findByName('Hardware');

$categorize->makeChildOf($parent);

Moving to a new root.

$category = Categorize::getCategoryProvider()->findByName('Hardware - CPU');

$category->makeRoot();

Moving to another parent.

$category = Categorize::getCategoryProvider()->findByName('Hardware - CPU');

$parent = Categorize::getCategoryProvider()->findByName('Software');

$category->makeChildOf($parent);

Update information.

$category = Categorize::getCategoryProvider()->findByName('Hardware - CPU');
$category->fill(array(
    'title'       => 'Software - Office',
    'description' => 'Documenting'
));

$category->save();

Delete with children.

$category = Categorize::getCategoryProvider()->findByName('Hardware');

$category->deleteWithChildren();

List category as tree.

$category = Categorize::getCategoryProvider()->findByName('Hardware');

var_dump($category->getChildren()->toArray());

Build categories as tree.

$categories = Categorize::getCategoryProvider()->whereType('Blog')->get();

// Build only root categories.

$categories = Categorize::getCategoryProvider()->root()->whereType('Blog')->get();

var_dump(Categorize::tree($categories)->toArray());

Using categorize with model.

Define relation to model

public function categories()
{
    return $this->morphMany('Teepluss\Categorize\CategoryRelates\Relate', 'contentable');
}

Push content to a category.

$category = Categorize::getCategoryProvider()->findByName('Hardware - CPU');

$blog = Blog::find(24);
$blog->categories()->create(array('category_id' => $category->id));

List contents that belongs to a category.

$contentIds = Categorize::getCategoryProvider()->findById(1)->relates()->whereContentableType('Blog')->lists('contentable_id');
// or
// $contentIds = Categorize::getCategoryRelateProvider()->whereContentableType('Blog')->whereCategoryId(1)->lists('contentable_id');

$blogs = Blog::find($contentIds);

var_dump($blogs->toArray());

Support or Contact

If you have some problem, Contact teepluss@gmail.com

Support via PayPal

统计信息

  • 总下载量: 333
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 8
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固