Check Here
Check Here

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

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

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.

. . .

Comment

Add Your Comment

Be the first to comment.

Bagisto helped us in creating this full functional, professional and user friendly web app. Bagisto has lot to offer to the developer and the user. The framework is outstanding.

Yosseph Baruch Dolgopolsky

Yosseph Baruch Dolgopolsky

allspot.store
Talk to Sales

Global

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
    css.php