Download the PHP package codezero/laravel-route-key-exists without Composer

On this page you can find all versions of the php package codezero/laravel-route-key-exists. 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-route-key-exists

Laravel Route Key Exists

[GitHub release]() [License]() Build Status Code Coverage Scrutinizer Code Quality Total Downloads

Laravel validation rule to check if a custom route key exists.

Laravel's exists rule checks a database table for a column with a given value. This validation rule uses the resolveRouteBinding() method on a model to check if a given value exists.

Requirements

Installation

Require the package via Composer:

Some Background Info

Laravel's implicit route model binding allows you to automatically resolve a model by type hinting it in a controller. Furthermore, you can change the route key that is used to query the database in your model:

This also works when you are using a custom or computed route key in your model:

But what if you are sending a custom key in a POST request and you want to validate it? Unlike Laravel's exists rule, this validation rule uses the resolveRouteBinding() method to check if the key is valid.

Usage

Let's say you have a model with an ID of 1, but getRouteKey() returns the encoded value of 1234.

In your validation rules, pass your model's class name to \CodeZero\RouteKeyExists\RouteKeyExists:

Here, model_id is the encoded value, which will be resolved using the resolveRouteBinding() method on your model. If it can't be resolved, validation fails.

Possibly, you will need the actual ID to work with when validation passes. Tack on replace() to the rule and model_id will be updated to the actual ID:

If your form uses a different attribute name than your model or database, you can replace the ID and the attribute name in the process.

Or maybe you want to keep the encoded ID in the request, but add the actual ID as well. Just tack on add() and specify an attribute name:

Beware that attributes that are dynamically added to the request will not be included in the array that is returned from request()->validate(). You can access those via request('attribute_name').

Useful Packages

Testing

Security

If you discover any security related issues, please e-mail me instead of using the issue tracker.

Changelog

See a list of important changes in the changelog.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-route-key-exists with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
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 codezero/laravel-route-key-exists contains the following files

Loading the files please wait ....