rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

Error when used with Observers #140

Closed rods closed 6 years ago

rods commented 7 years ago

Lumen 5.3. Throws Target [Conner\Tagging\Contracts\TaggingUtility] is not instantiable. When Model is registered as an Observer

class EventServiceProvider extends ServiceProvider {
public function boot()
    {
        parent::boot();
        Posts::observe(PostsObserver::class);
    }
}
Class PostObserver {

public function created(Posts $post)
    {
}
}
class Posts extends Model
{
    use SoftDeletes;

    use Taggable;
}
rods commented 7 years ago

anyone on this?!

rtconner commented 7 years ago

I haven't had any time. If you resolve it please make a pull request.

dhilowitz commented 6 years ago

@rods Were you ever able to figure this out? I'm having a similar issue.

rods commented 6 years ago

@dhilowitz Hi...nop! Since this project is dead i prefered to code a small lib to our needs.

mian3010 commented 6 years ago

I also had this problem. It turned out to be a matter of ordering. I registered the observers in a ServiceProvider, that was referenced before the ServiceProvider from this module. Swapping the order made it work.

prog-24 commented 6 years ago

Make your provider that boots the observer come last. In most cases, that is the EventServiceProvider