cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
537 stars 72 forks source link

How to I get $model #114

Closed warmwhisky closed 3 years ago

warmwhisky commented 4 years ago

Please be sure you include all the relevant information in your issue so we can help you:

Hi,

I am not sure how I initialise the $model variable in your usage docs? What am I missing?

Thanks

cviebrock commented 3 years ago

Hi,

You can create or retrieve any model using the regular Laravel methods:

$model = new MyModel($attributes);

// or
$model = MyModel::find(1);

// or
$model = MyModel::where(...)->first();

// etc.

Once you have an instance of your model class, then you can tag it as per the docs for this package.

$model->tag('cool', 'new');$model->tag(['Apple', 'Banana', 'Cherry']);
$model->save();