Cannot attach tag to model
danielthomascarr opened this issue · comments
Daniel Carr commented
followed installation instructions using Laravel 7 and added to model
namespace App;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Spatie\Tags\HasTags;
class Product extends Model
{
use HasTags;
}
used Tinker
$product = App\Product::find(1); created a tag manually in database, tried to attach
$product->attachTag('tag4');
but get error
BadMethodCallException with message 'Call to undefined method App/Product::attac
hTag()'
I think the model is not attached because I can create a tag using
$product->attachTag(\Spatie\Tags\Tag::findOrCreate('tag3', 'something'));
which creates the tag but doesn't attach it to the model and don't know why?
Daniel Carr commented
composer dumpautoload to the rescue