mgallegos / laravel-jqgrid

@Laravel jqGrid package allows you to easily integrate the popular @jQuery Grid Plugin (jqGrid) into your Laravel application.
mariogallegos.com
Other
69 stars 44 forks source link

Already using repository #8

Closed rbruhn closed 10 years ago

rbruhn commented 10 years ago

How can you integrate this if you are already extending your own custom repositories and interfaces? $this->GridEncoder->encodeRequestedData expects Mgallegos\LaravelJqgrid\Repositories\RepositoryInterface

mgallegos commented 10 years ago

I'm going to assume that you are implementing your own repository, if that the case, what you have to do is create a class that implement the RepositoryInterface, this way you can keep using the GridEncoder which is the one in charge to sent the data to the grid in the correct format.

rbruhn commented 10 years ago

Yes, I have my own repository. It looks like this:

class ExpeditionRepository extends Repository implements ExpeditionInterface {}

Technically, I guess I could add RepositoryInterface as well, right?

class ExpeditionRepository extends Repository implements ExpeditionInterface, RepositoryInterface {}

Then add a binding for RepositoryInterface to my ExpeditionRespository?

Or, as you say.... make a completely new Repo specifically for this?

mgallegos commented 10 years ago

Yes, PHP allows you to implement more than one interface so if do that it should work fine.

The only issue is that implementing the RepositoryInterface is a lot of work, that why I included the EloquentRepositoryAbstract class in the package so you can extend it because it will be make your life easier if you are using Query Builder or Eloquent ORM.

If you are using Query Builder or Eloquent ORM you can also copy and paste the code of the EloquentRepositoryAbstract to your existing class (the one implementing the RepositoryInterface) and it should work too.