<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
touhidurabir / laravel-multi-key-route-binding example snippets
use Touhidurabir\MultiKyeRouteBinding\HasMultipleRouteBindingKeys;
use Illuminate\Database\Eloquent\Model;
class User extends Model {
use HasMultipleRouteBindingKeys;
}
/**
* The attributes that will be used for multiple key binding on route models
*
* @var array
*/
protected $routeBindingKeys = [
'email',
'username'
];
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
/**
* Use the model's own route key name (its primary key) instead of 'id'
*
* @var bool
*/
protected $useModelRouteKeyName = true;
use Touhidurabir\MultiKyeRouteBinding\Facades\MultiKyeRouteBinding;
MultiKyeRouteBinding::resolve(User::class, '[email protected]'); // by id, email or username
MultiKyeRouteBinding::resolve(User::class, '[email protected]', 'email'); // only by email
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.