IfnotFr / eloquent-vuex-php

Realtime model synchronization between Vuex (VueJs) and Eloquent (Laravel).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Interface

mathieutu opened this issue · comments

IMO, a better way to do that is to implement an interface on your models.
So your models implements interface should have some methods, which are provided by your trait.

https://github.com/Ifnot/laravel-vuex-php/blob/9fd0997a7decf442c1663c291b0179b6bef11d55/src/Events/MutationEvent.php#L25

So your method could be like that if your interface is called IsStoreInterface (name to find):

 /**
     * Create a new event instance.
     *
     * @param IsStoreInterface $model
     * @param $mutation
     * @throws \Exception
     */
    public function __construct(IsStoreInterface $model, $mutation)
    {
        $this->model = $model;
        $this->store = $model->getStore();
        $this->mutation = $mutation;
    }

Don't you think adding a trait and interface looks overkill ? It is just for one method getStore :/