namest/taxonomy
最新稳定版本:v0.2
Composer 安装命令:
composer require namest/taxonomy
包简介
README 文档
README
Provide an elegant way to interact with taxonomies (tags, category, ...) in your Laravel app.
Note: The package is only support Laravel 5
Installation
Step 1: Install package
composer require namest/taxonomy
Step 2: Register service provider in your config/app.php
return [ ... 'providers' => [ ... 'Namest\Taxonomy\TaxonomyServiceProvider', ], ... ];
Step 3: Publish package migrations. Open your terminal and type:
php artisan vendor:publish --provider="Namest\Taxonomy\TaxonomyServiceProvider"
Step 4: Migrate the migration that have been published
php artisan migrate
Step 5: Create taxonomies in your terminal by artisan command
php artisan make:taxonomy Color
This command will create a taxonomy in database and make the Color model in app/Color.php to reflect that taxonomy.
Step 6: Read API below and start happy
API
$tag = new Tag; $tag->name = 'new tag'; $tag->slug = 'new-tag'; $tag->save(); $childTag = new Tag; $childTag->name = 'child tag'; $childTag->slug = 'child-tag'; $childTag = $tag->childs->save($childTag); $parent = $childTag->parent;
$tag = Tag::first();
echo $tag->name;
echo $tag->slug;
$childs = $tag->childs;
// Find tag has slug is 'new-tag'
$tag = Tag::hasSlug('new-tag')->first();
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-05