Download the PHP package jobmetric/laravel-barcode without Composer
On this page you can find all versions of the php package jobmetric/laravel-barcode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jobmetric/laravel-barcode
More information about jobmetric/laravel-barcode
Files in jobmetric/laravel-barcode
Package laravel-barcode
Short Description This is a barcode management package for Laravel that you can use in your projects.
License MIT
Homepage https://doc.jobmetric.net/package/laravel-barcode
Informations about the package laravel-barcode
Barcode for laravel
This is a barcode management package for Laravel that you can use in your projects.
Install via composer
Run the following command to pull in the latest version:
Documentation
Undergoing continuous enhancements, this package evolves each day, integrating an array of diverse features. It stands as an indispensable asset for enthusiasts of Laravel, offering a seamless way to harmonize their projects with barcode database models.
In this package, you can employ it seamlessly with any model requiring database barcode.
Now, let's delve into the core functionality.
Before doing anything, you must migrate after installing the package by composer.
Meet the HasBarcode
class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:
In the first step, you need to connect this class to your main model.
How is it used?
Storing a barcode
You can now use the HasBarcode
class to store barcodes for your model. The following example shows how to create a new product by saving a barcode:
In this example, we created a new product and saved it to the database. Then, we stored a barcode for the product using the storeBarcode
method. The first parameter is the barcode type, and the second parameter is the barcode value.
Retrieving a barcode
You can retrieve a barcode for a model using the getBarcode
method. The following example shows how to retrieve a barcode for a product:
In this example, we retrieved a product from the database and then retrieved the barcode for the product using the getBarcode
method. The parameter is the barcode type.
Deleting a barcode
You can delete a barcode for a model using the deleteBarcode
method. The following example shows how to delete a barcode for a product:
In this example, we retrieved a product from the database and then deleted the barcode for the product using the forgetBarcode
method. The parameter is the barcode type.
Delete all barcodes
You can delete all barcodes for a model using the deleteAllBarcodes
method. The following example shows how to delete all barcodes for a product:
In this example, we retrieved a product from the database and then deleted all barcodes for the product using the forgetAllBarcodes
method.
Checking if a barcode exists
You can check if a barcode exists for a model using the hasBarcode
method. The following example shows how to check if a barcode exists for a product:
In this example, we retrieved a product from the database and then checked if a barcode exists for the product using the hasBarcode
method. The parameter is the barcode type.
Updating a barcode
You can update a barcode for a model using the storeBarcode
method. The following example shows how to update a barcode for a product:
In this example, we retrieved a product from the database and then updated the barcode for the product using the storeBarcode
method. The first parameter is the barcode type, and the second parameter is the new barcode value.
Add barcodeable attribute in Resource
In the barcode resource, there is a field called bacodeable
that can display your model, but it must be set as follows.
First, you create a listener for the model you want to display in the barcode resource.
Then, you add the following code to the listener.
Finally, you add the listener to the EventServiceProvider
class.
The work is done, now when the BarcodeResource is called and if the ProductResource should be returned, the details of that resource will be displayed in the barcodeable attribute.
Barcode Types
This package supports the following barcode types:
code128
code39
code93
codabar
ean13
ean8
upc
upcext
isbn
datamatrix
pdf417
qrcode
itf14
interleaved2of5
postnet
msi
pharmacode
maxicode
aztec
code11
code128a
code128b
code128c
code39extended
code39mod43
code93extended
gs1_128
gs1_128composite
gs1_cc
gs1datamatrix
gs1datamatrixrectangular
gs1qrcode
Events
This package contains several events for which you can write a listener as follows
Event | Description |
---|---|
BarcodeStoredEvent |
This event is called after storing the barcode. |
BarcodeUpdateEvent |
This event is called after updating the barcode. |
BarcodeForgetEvent |
This event is called after forgetting the barcode. |
Contributing
Thank you for considering contributing to the Laravel Barcode! The contribution guide can be found in the CONTRIBUTING.md.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-barcode with dependencies
laravel/framework Version >=9.19
jobmetric/laravel-package-core Version ^1.7