Download the PHP package iqbalatma/laravel-service-repo without Composer

On this page you can find all versions of the php package iqbalatma/laravel-service-repo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-service-repo

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

How to install

Use composer to install Laravel Service Repository Package

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

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.

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

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.

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

How to call repository from service

You can call method on repository via static or non-static method.

[!NOTE] Here is example call repository via static method

[!NOTE] Here is example call repository via non-static method

Predefined Method Query

You can call predefied method from service. Here is list of predefined method query and it's use case.

You can also chaining method before predefined method query.

[!NOTE] Here is how to use predefined method with chaining method for additional query

How to add predefined method

You can also create your own method on repository. For example you want to create query that will be execute in many place and want to avoid redundant code.

[!IMPORTANT] Create predefined method query with query prefix. So you can call statically without query prefix. Example : UserRepository::getAllActiveUser()

How to call model scope on repository

Sometimes you want to create model local scope and still want to use repository to call it.

you can call this scope TagRepository::active()->getAllDataPaginated();

How to use orderColumn method

Order column is predefined method that will use query param from http request for order requested data. Before use order column you need to defined column that allowed to order. You can define that orderable column inside the model.

As you can see, property $orderableColumns is array that has key and value. Key of this property is use to key from http request. You can customize this key into whatever you want The value of this property is mapping to column name of database table

To use this order you just need to call orderColumn method when calling repository

In other condition you can also pass parameter into orderColumn method to override orderable column

How to use filterColumn method

Filter column is predefined method to filter data via query param from http request Before use filterColumn method, you need to define list of column that allowed to filter

[!IMPORTANT] All of filter query using operator '=', but you can define custom operator based on your needs

To use filter column you just need to call and chain this method. You can also chain with other method like orderColumn

In other condition you can also pass parameter into filterColumn method to override filterable column

[!NOTE] You can also filter column on relation. But you need to define relation and filterable column on model

You when you want to filter relation of model, you need to make sure the relation is already defined. And then you need to create $relationFilterableColumns property. The key of this property is relation name and the value is filterable column just like $filterableColumns property.

[!NOTE] You can also override relation filterable column just pass array filterable column on second argumen of filterColumn. Example : filterColumn([], [ "profile" => [ "phone" => "profiles.pone" ] ])

How to custom operator on filterColumn

You just need to define array for column and operator


All versions of laravel-service-repo with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iqbalatma/laravel-service-repo contains the following files

Loading the files please wait ....