PHPackages                             iqbalatma/laravel-service-repo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. iqbalatma/laravel-service-repo

ActiveLibrary[Framework](/categories/framework)

iqbalatma/laravel-service-repo
==============================

Project for extend base class on laravel with service repo pattern

5.0.0(1y ago)31.8kPHPPHP &gt;=8.0

Since Jan 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/iqbalatma/laravel-service-repo)[ Packagist](https://packagist.org/packages/iqbalatma/laravel-service-repo)[ RSS](/packages/iqbalatma-laravel-service-repo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (78)Used By (0)

Laravel Service Repository
==========================

[](#laravel-service-repository)

Laravel Service Repository is laravel package for service repository pattern. Service repository pattern helps you to separate concern and move logic into service class. From service class you can query all of your data from repository, not directly using model. This will help you to avoid redundant query and make it easier to maintain.

Upcomming
=========

[](#upcomming)

- Customize root of filter and order by config
- Publish service stub for customization
- Testing
- Type hint for predefined method on repository extend

How to install
==============

[](#how-to-install)

Use composer to install Laravel Service Repository Package

```
composer require iqbalatma/laravel-service-repo

```

Concept
=======

[](#concept)

Here is concept of service repository, you can see diagram below Controller will handle only http request and http response. This will make your controller thin. All of data from request will be validate on Validation class. All validation rule will be defined here After all data validated, data will be passed to service. In service, all of business logic works. Every business logic that need data or modify data from database will be communicate via repository. This repository already have some predefined query, but you are free to customize predefined query as you need.

[![Screenshot 2023-09-28 at 00 55 06](https://private-user-images.githubusercontent.com/35129050/271071707-cdd0c078-a83c-4002-bae6-d21ab03ff932.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImt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E4NTAyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE2MGMyM2RmNjkzYTQ5MDA4MmE1NjU4NTNkMTQ5MWFkZDY5MTk3ZTJiNGI4ODk2N2ZkY2U4NjQzMmRjNTY5ZmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.XXJzzyL_3hIhebVy8UgipNt513PCQiVyCaezBHHTMIk)Service
=======

[](#service)

Service is use for your business logic. You can call service from controller or from another service. This package have base service and you can extend to this service. You can also generate service via artisan command.

```
php artisan make:service UserService

```

This command will generate service for you in ***App/Services*** directory.

Repository
==========

[](#repository)

Use repository to query your database via model. So you do not need to write same query twice. You can generate repository on directroy ***App/Repositories*** via artisan command.

```
php artisan make:repository UserRepository

```

This command will generate repository for you in ***App/Repositories*** directory Here is example of UserRepository.

```
