定制 uptoolkit/laravel-categories 二次开发

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

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

uptoolkit/laravel-categories

最新稳定版本:1.0.0

Composer 安装命令:

composer require uptoolkit/laravel-categories

包简介

Associate Eloquent Models with Categories

README 文档

README

Build Status PHP from Packagist Latest Version License

Installation

Require this package, with Composer, in the root directory of your project.

$ composer require uptoolkit/laravel-categories

To get started, you'll need to publish the vendor assets and migrate:

php artisan vendor:publish --provider="Uptoolkit\Categories\CategoriesServiceProvider" && php artisan migrate

Usage

Nested Sets

Check lazychaser/laravel-nestedset to learn how to create, update, delete, etc. categories.

Setup a Model

<?php

namespace App;

use Uptoolkit\Categories\Traits\HasCategories;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasCategories;
}

Examples

Get an array with ids and names of categories (useful for drop-downs)

$post->categoriesList();

Attach the Post Model these Categories

$post->syncCategories([Category::find(1), Category::find(2), Category::find(3)]);

Detach the Post Model from these Categories

$post->syncCategories([]);

Detach the Post Model from all Categories and attach it to the new ones

$post->syncCategories([Category::find(1), Category::find(3)]);

Attach the Post Model to the given Category

$post->assignCategory(Category::find(1));

Detach the Post Model from the given Category

$post->removeCategory(Category::find(1));

Get all Posts that are attached to the given Category

Category::first()->entries(Post::class)->get();

Testing

$ phpunit

Security

If you discover a security vulnerability within this package, please send an e-mail to hello@brianfaust.me. All security vulnerabilities will be promptly addressed.

Credits

License

MIT © Brian Faust

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固