1. Go to this page and download the library: Download robotsinside/laravel-tags library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robotsinside / laravel-tags example snippets
/*
* Package Service Providers...
*/
\RobotsInside\Tags\TagsServiceProvider::class,
namespace App;
use Illuminate\Database\Eloquent\Model;
use RobotsInside\Tags\Taggable;
class Post extends Model
{
use Taggable;
}
use App\Post;
use Illuminate\Support\Facades\Route;
use RobotsInside\Tags\Models\Tag;
Route::get('/', function () {
// Retrieve a new or existing tag
$tag1 = (new Tag())->resolve('Tag 1');
$tag2 = (new Tag())->resolve('Tag 2');
// Or, retrieve a collection of new or existing tags
$tags = (new Tag())->resolveAll(['Tag 1', 'Tag 2', 'Tag 3'])
$post = new Post();
$post->title = 'My blog';
$post->save();
$post->tag($tag1);
// Or
$post->tag(['tag-1']);
// Or
$post->tag([1, 2]);
// Or
$post->tag(Tag::get());
});
use App\Post;
use Illuminate\Support\Facades\Route;
use RobotsInside\Tags\Models\Tag;
Route::get('/', function () {
$tag1 = Tag::find(1);
$post = Post::where('title', 'My blog')->first();
$post->untag($tag1);
// Or
$post->untag(['tag-1']);
// Or
$post->untag([1, 2]);
// Or
$post->untag(Tag::get());
// Or
$post->untag(); // remove all tags
});
sh
php artisan vendor:publish --provider="RobotsInside\Tags\TagsServiceProvider" --tag="migrations"
sh
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.