• Guest, we are currently accepting crypto payments.

Creating Repositories

Riste

PixelTech Developer
Staff member
Administrator
Customer
It is recommended that you extend and make custom functions within Repositories. To do this, we simple extend our AbstractRepository class.

PHP:
namespace MyAddonId\Repository;
use \MyDownloads\Repository\AbstractRepository;
class MyCustomRepository extends AbstractRepository
{
    /*
     We must implement abstracted public method getContentType()
     to be able to access to getModel() eloquent model
     */
    public function getContentType()
    {
        return 'Groups'; // We will make instanceof model Groups, so later when we will do $this->getModel() will return model.
    }
    public function myCustomMethod()
    {
        // To access Model instance we simple run:
        $this->getModel(); // Will return eloquent model instance
    }
}

AbstractRepository gives you few methods:
  1. getModel() // will return instance of the eloquent model.
  2. finder ( Currently in development )
  3. insertRecord(array $data) // accept array data and insert it to the model. This does not validate for multiple data
 
Top