Download the PHP package lecturize/laravel-taxonomies without Composer

On this page you can find all versions of the php package lecturize/laravel-taxonomies. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-taxonomies

Latest Stable Version Total Downloads License

Laravel Taxonomies

Simple, nestable Terms & Taxonomies (similar to WordPress) for Laravel.

Installation

Require the package from your composer.json file

and run $ composer update or both in one with $ composer require lecturize/laravel-taxonomies.

Configuration & Migration

This will publish a config/sluggable.php, a config/lecturize.php and some migration files, that you'll have to run:

For migrations to be properly published ensure that you have added the directory database/migrations to the classmap in your projects composer.json.

Usage

First, add our HasCategories trait to your model.

Add a Term
Add multiple Terms
Add a Term with optional parent_id (taxonomy->id) & sort order
Get all Terms for a model by taxonomy
Get a specific Term for a model by (optional) taxonomy
See if model has a given category within given taxonomy
Remove a Term from model by (optional) taxonomy
Remove (detach) all categories relations from model
Scope models with any of the given categories
Scope models with one category

Helper functions

I've included a set of helper functions for your convenience, see src/helpers.php.

Custom taxonomy model

Make sure to create a custom Taxonomy model, that extends Lecturize\Taxonomies\Models\Taxonomy.

Don't forget to publish the config file and update the value of lecturize.taxonomies.taxonomies.model to \App\Models\Post:class.

Example

Add categories to an Eloquent model

First, this snippet will create three entries in your terms table, if they don't already exist:

Then it will create three entries in your taxonomies table, relating the terms with the given taxonomy "category".

And last it will relate the entries from your taxonomies table with your model (in this example a "Post" model) in your pivot table.

Why three tables?

Imagine you have a Taxonomy called post_cat and another one product_cat, the first categorises your blog posts, the second the products in your online shop. Now you add a product to a category (a term) called Shoes using $product->addCategory('Shoes', 'product_cat');. Afterwards you want to blog about that product and add that post to a post_cat called Shoes as well, using $product->addCategory('Shoes', 'post_cat');.

Normally you would have two entries now in your database, one like ['Shoes','product_cat'] and another ['Shoes','post_at']. Oops, now you recognize you misspelled Shoes, now you would have to change it twice, for each Taxonomy.

So I wanted to keep my Terms unique throughout my app, which is why I separated them from the Taxonomies and simply related them.

Changelog

[2021-02-09] v1.0

Extended the database tables to support UUIDs (be sure to generate some on your existing models) and better customization. Quite some breaking changes throughout the whole package.

[2022-05-16] v1.1

Updated dependencies to PHP 8 and Laravel 8/9 - for older versions please refer to v1.0. Added new columns like content, lead, meta_desc, visible and searchable to taxonomies table. Renamed the term scope on the Taxonomy model to byTerm to avoid confusion with its term relationship method.

[2022-06-04] v1.2

Removed the Taxable model, you should create a custom Taxonomy model in your project that extends Lecturize\Taxonomies\Models\Taxonomy and contain your project-specific morphedByMany relations, e.g. posts. Don't forget to override the config value of config('lecturize.taxonomies.taxonomies.model') accordingly.

On the taxable pivot table a primary key has been added, make sure you have no duplicates in that table before publishing and running the new migrations! Also, timestamps have been added to the pivot table.

If you are using the get_categories_collection() or build_categories_collection_from_tree() helper function or Taxonomy::getTree() review the slightly adapted signatures. Instead of a taxables class (e.g. \Post:class) through the $taxable argument, we now ask for a $taxable_relation (e.g. the posts relation on your custom taxonomy model). If you continue to pass a class name like \Post:class we'll try and guess the relation by using Str::plural().

License

Licensed under MIT license.

Author

Handcrafted with love by Alexander Manfred Poellmann in Vienna & Rome.


All versions of laravel-taxonomies with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^8.0|^9.0
illuminate/database Version ^8.0|^9.0
webpatser/laravel-uuid Version ^3.0|^4.0
cviebrock/eloquent-sluggable Version ^8.0|^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lecturize/laravel-taxonomies contains the following files

Loading the files please wait ....