Download the PHP package pascalvgemert/laravel-lookupable without Composer

On this page you can find all versions of the php package pascalvgemert/laravel-lookupable. 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-lookupable

Laravel Lookupable

Lookupable Trait for Laravel eloquent models for quick and efficient table lookups.

Total Downloads License

Requires Laravel 5.5 or higher!

About the package

When building more complex applications, lookup queries can add up without you even knowing. The lookupable trait will only get the lookup instances once per request and store them in memory. Every next time you want to lookup a lookupable instance of the same Model, the lookup methods will access the in memory stored instances and prevent a query.

Example: You have a lookup table for statuses like pending, draft, published, deleted. You can access these instances multiple times, with only one query per request:

Installation

You can install the package via composer:

Usage

The Lookupable trait can be used only for Eloquent Models

Example table scheme for 'Roles'

id identifier title
1 admin Admin User
2 user System User
3 guest Guest User

Lookupable methods

After this you can lookup instances easily with the following methods:

Single Lookup

Single Lookup which throws an \Illuminate\Database\Eloquent\ModelNotFoundException error when no record could be found

Multiple Lookup

Multiple Lookup which throws an \Illuminate\Database\Eloquent\ModelNotFoundException error when any of the given record could NOT be found

Soft Deleted items

All of the above methods can except a second parameter (bool $withTrashed = false;), to also return with Soft Deleted items.

Note: When trying to use the Soft Deleted items, please make sure your Eloquent Model implements the \Illuminate\Database\Eloquent\SoftDeletes trait.

I don't have an identifier column?

So your database table doesn't contain an identifier column and looks like this Country table for example:

id code title
1 NL Netherlands
2 UK Great Brittain
3 BE Belgium
4 US United States
5 ... ...

No worries, you can define your own lookup column name in your model like so:

Credits


All versions of laravel-lookupable with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/database Version 5.5.x|5.6.x|5.7.x|5.8.x
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 pascalvgemert/laravel-lookupable contains the following files

Loading the files please wait ....