Download the PHP package nestermaks/laravel-pricelist without Composer
On this page you can find all versions of the php package nestermaks/laravel-pricelist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nestermaks/laravel-pricelist
More information about nestermaks/laravel-pricelist
Files in nestermaks/laravel-pricelist
Package laravel-pricelist
Short Description Multilingual pricelist package for Laravel with migrations and API controllers
License MIT
Homepage https://github.com/nestermaks/laravel-pricelist
Informations about the package laravel-pricelist
Multilingual pricelist package for Laravel with migrations and API controllers
This package allows you to manage your pricelists and reorder items inside. It's not a kind of pricing tables, where you have a list of features and a price below. It is responsible for creating lists, where every item has its own price. Also every item can belong to many pricelists.
This package includes:
- Models
- Migrations
- Api routes
- Api controllers
- Translations
- Config file
Table of contents
- Installation
- Configuration
- Database
- Usage
- Registering models
- Associating pricelists
- Show pricelists and pricelist items
- Attach and detach pricelist items to pricelist
- Reordering pricelist items within the pricelist
- Api Routes
- CRUDS
- Pricelists
- Pricelist items
- Attach and detach pricelists from pricelist items
- Associate pricelist with your model
- Change pricelist item order within a pricelist
- CRUDS
- Testing
- Changelog
- Contributing
- Security vulnerabilities
- Credits
Installation
You can install the package via composer:
Publish and run the migrations with:
Configuration
You can override translation files of add a new one. Publish lang files with:
You can override the default options for used locales, api route prefixes and validation rules. Publish the configuration:
This is the contents of the published config file:
Database
Migrations files are provided with such tables:
-
pricelists. This table is like a container for pricelist items. It has such fields:
order
- sets priority on a frontendactive
- defines if the pricelist is active or not
Translatable fields of the table 'pricelists' are in the table 'pricelist_translations'. Table 'pricelists' has many pricelist translations
- pricelist_translations. Fields:
pricelist_id
- id of the related pricelistlocale
- language of translationtitle
- title of the pricelistdescription
- description of the pricelist if needed
-
pricelist_items. Elements of pricelists. Fields:
shortcut
- for internal usage to identify your pricelist item. For example, if you have different items with the same titleprice
- price of your product. In case the 'max_price' field is set, this one stands for minimum price.max_price
- if your product has no fixed price this field describes maximum price.price_from
- if the price of your product starts from the value set in 'price' field and has no upper bound. Boolean.active
- defines if the pricelist item is active or not
Translatable fields of the table 'pricelist_items' are in the table 'pricelist_items_translations'. Table 'pricelists' has many pricelist translations
- pricelist_items_translations. Fields:
pricelist_item_id
- id of the related pricelist itemlocale
- language of translationtitle
- name of your productunits
- in what units your product can be calculated
-
pricelist_pricelist_item. Pivot table for pricelists and pricelist_items in many to many relationship. Also contains field 'item_order', which defines order of an element within the table.
- pricelistables. Polymorphic many to many relationship table. Responsible for attaching a pricelist to your pricelistable models.
Usage
Registering Models
To let your models be able to attach pricelists, add the HasPricelist trait to your model class
Associating pricelists
You can associate a pricelist with a model like this:
Or you can detach pricelist from a model:
To watch all pricelists of the model:
Show pricelists and pricelist items
To show all active pricelists:
The same for pricelist items
To show pricelist items related to the pricelist:
To show pricelists where the pricelist item is present:
Attach and detach pricelist items to pricelist
Assuming we have such variables:
To attach items to the pricelist:
Or to attach one pricelist item to many pricelists:
To detach items from the pricelist:
To detach item from given pricelists:
Notice that the argument in all these cases is a Collection.
Reordering pricelist items within the pricelist
When you attach pricelist items to the pricelist, each of them gets its order number. To see order number of a pricelist item in the pricelist use:
or
To set a new order number of a pricelist item within the pricelist use:
or
Second argument is for new order number. After you assign a new order number of the pricelist item, another ones will rearrange appropriately inside the pricelist.
Api routes
You may use api calls to manage your pricelists. Set desired api prefixes in a config file or leave it default. For pricelists and pricelists items CRUDS are used api resource routes with api resource controllers. You may look through the Laravel DOCS.
CRUDS
Pricelists
Parameters to use in CRUDS:
- title
- description
- lang
- order
- active
For example, to update a pricelist with id "12" make a patch request:
Pricelist items
Parameters to use in CRUDS:
- title
- units
- lang
- shortcut
- price
- max_price
- price_from
- active
For example, to update a pricelist with id "12" item make a patch request:
Attach and detach pricelists from pricelist items
Make a POST request. URL should look like:
Parameters:
- action (can be 'detachItems' or 'attachItems')
- pricelist_id
- pricelist_items_id
One of the parameters of pricelist_id and pricelist_items_id should be an integer while another one should be an array.
Example:
Associate pricelist with your model
Make a POST request. URL should look like:
Parameters:
- action (can be addPricelist or removePricelist)
- model_name (should be a fully qualified class name of your model)
- model_id
- pricelist_id
Example:
Show related pricelists of your model
Make a GET request. URL should look like:
Parameters:
- model_name (should be a fully qualified class name of your model)
- model_id
Example:
Change pricelist item order within a pricelist
Make a POST request. URL should look like:
Parameters:
- pricelist_id
- pricelist_item_id
- item_order (new order number of the pricelist item in a pricelist)
Example:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- nestermaks
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-pricelist with dependencies
astrotomic/laravel-translatable Version ^11.9
illuminate/contracts Version ^8.37
spatie/laravel-package-tools Version ^1.4.3