How to store data from Repository in Bagisto

In Bagisto we use a Repository pattern for interacting with the Database and before going forward to create the files we have to understand some concepts e.g – Contracts, Repository, and Model Proxies


Contracts are a set of interfaces that define the core services provided by the Laravel framework. For example, the Illuminate\Contracts\Mail\Mailer contract defines the methods needed for sending an e-mail.


Repositories create a bridge between models and controllers. Decouple the hard dependencies of models from the controllers. The model should not be responsible for communicating with or extracting data from the database

Model Proxies

The concept of Model proxies has been introduced to override the functionality of the existing Model. It is a type of model inheritance without creating a new table in the database.

Now, Let’s Get Started,

Step 1

First, we have to create a Model in packages/Webkul/HelloWorld/src/Models as illustrated below

Step 2

Now create an interface in a folder named Contract path packages/Webkul/HelloWorld/src/Contract and also implement the interface class in the above Model class

Step 3

In Bagisto we create a layer above the Model which we called Model Proxy. For this, we have to create a class where the Model exists which extends a class Konekt\Concord\Proxies\ModelProxy as illustrated below

Step 4

Now create a folder Repositories in which create a class HelloWorldRepository.php that extends Webkul\Core\Eloquent\Repository and create a method model() in the class that returns the path of the contract

Step 5

After creating the above files, Create a Service Provider as ModuleServiceProvider.php  which extends the Konekt\Concord\BaseModuleServiceProvider as illustrated below

Step 6

Now Register the Service Provider in the config/concord.php file

Now Run command


We will consistently update blog posts, so don’t forget to keep a check on it regularly. Also for any queries or doubts reach out to us at [email protected]. You can also raise a ticket at our HelpDesk System.

. . .


Add Your Comment

Be the first to comment.

I was into Multivendor project for my client and I just found out that Bagisto was literally killing it. Their works and efforts are really awesome. But It truly was a jaw-drop with the Support. "Bagisto" is really a Ecommerce Enabler for sure! One of the guys from the support team called Saurabh Dutta but I used to call Dutta. He really helps with all my questions and enquires. He even helps and supports on the way back home. We also talked about Covid and other external factors. Well, thanks for everything.

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home