diff --git a/README.md b/README.md index c8d5243..e8cebea 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ This package is not meant to handle javascript or html in any way. This package There are no real limits on what characters can be used in a tag. It uses a slug transform to determine if two tags are identical ("sugar-free" and "Sugar Free" would be treated as the same tag). Tag display names are run through Str::title() -[Laravel 5 Documentation](https://github.com/rtconner/laravel-tagging/tree/laravel-5) +[Laravel/Lumen 5 Documentation](https://github.com/rtconner/laravel-tagging/tree/laravel-5) [Laravel 4 Documentation](https://github.com/rtconner/laravel-tagging/tree/laravel-4) -#### Composer Install (for Laravel 5) +#### Composer Install (for Laravel/Lumen 5) ```shell composer require rtconner/laravel-tagging "~2.0" @@ -33,6 +33,22 @@ php artisan vendor:publish --provider="Conner\Tagging\Providers\TaggingServicePr php artisan migrate ``` +###### lumen + +Laravel does not have a vendor:publish command, so you will need to create or copy the provided migrations and config file into their respective directory. + +In app\bootstrap\app.php + +```php +// Add this line in your config section +$app->configure('tagging'); +// Add this line in your service provider section +$app->register(Conner\Tagging\Providers\LumenTaggingServiceProvider::class); +``` + +Done. Eloquent is required, Facades are not. + + After these two steps are done, you can edit config/tagging.php with your prefered settings. #### Setup your models diff --git a/migrations/2014_01_07_073615_create_tagged_table.php b/migrations/2014_01_07_073615_create_tagged_table.php index 5f9bf4c..5864015 100644 --- a/migrations/2014_01_07_073615_create_tagged_table.php +++ b/migrations/2014_01_07_073615_create_tagged_table.php @@ -8,7 +8,7 @@ class CreateTaggedTable extends Migration { public function up() { Schema::create('tagging_tagged', function(Blueprint $table) { $table->increments('id'); - if(\Config::get('tagging.primary_keys_type') == 'string') { + if(config('tagging.primary_keys_type') == 'string') { $table->string('taggable_id', 36)->index(); } else { $table->integer('taggable_id')->unsigned()->index(); diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 87312a5..7832d45 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -34,7 +34,7 @@ public function __construct(array $attributes = array()) */ public function save(array $options = array()) { - $validator = \Validator::make( + $validator = app('validator')->make( array('name' => $this->name), array('name' => 'required|min:1') ); diff --git a/src/Providers/LumenTaggingServiceProvider.php b/src/Providers/LumenTaggingServiceProvider.php new file mode 100644 index 0000000..9abba1b --- /dev/null +++ b/src/Providers/LumenTaggingServiceProvider.php @@ -0,0 +1,41 @@ +app->singleton(TaggingUtility::class, function () { + return new Util; + }); + } + + /** + * (non-PHPdoc) + * @see \Illuminate\Support\ServiceProvider::provides() + */ + public function provides() + { + return [TaggingUtility::class]; + } +} diff --git a/src/Taggable.php b/src/Taggable.php index d8e085b..d73c835 100644 --- a/src/Taggable.php +++ b/src/Taggable.php @@ -7,7 +7,6 @@ use Conner\Tagging\Events\TagRemoved; use Conner\Tagging\Model\Tagged; use Illuminate\Database\Eloquent\Collection; -use Illuminate\Support\Facades\Config; /** * Copyright (C) 2014 Robert Conner @@ -301,7 +300,7 @@ public static function untagOnDelete() { return isset(static::$untagOnDelete) ? static::$untagOnDelete - : Config::get('tagging.untag_on_delete'); + : config('tagging.untag_on_delete'); } /** @@ -309,7 +308,7 @@ public static function untagOnDelete() */ public static function shouldDeleteUnused() { - return Config::get('tagging.delete_unused_tags'); + return config('tagging.delete_unused_tags'); } /**