cartalyst / tags

A Tagging package that easily allows you to add tags to your Eloquent models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FatalThrowableError: Call to a member function pluck() on string

huntercarter opened this issue · comments

I'm getting this error

(1/1) FatalThrowableError
Call to a member function pluck() on string
in TaggableTrait.php (line 193)

when calling setTags(). However tag() works fine.

Any advice would be appreciated.

What version of the package and Laravel are you using?

Also, how to reproduce the issue?

Laravel 5.4, and V.4.0.* of tags.

To trigger the exception, try running tag() and setTags() with a vanilla model, such as this:

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Cartalyst\Tags\TaggableTrait;
use Cartalyst\Tags\TaggableInterface;

class URL extends Model implements TaggableInterface
{
    use TaggableTrait;     
} 

?>

I'm not able to reproduce this.

I used the model you just pasted (just renamed it to Url instead of URL) and ran the following:

$url = App\Url::first();

$url->setTags(['tag one', 'tag two']);

var_dump($url->tags->pluck('slug'));

It works as expected.

The test suite is all green so it must be something else.