Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • balping/laravel-hashslug
  • aamirchaudhary/laravel-hashslug
  • jijoel/laravel-hashslug
  • rognales/laravel-hashslug
  • sdkakcy/laravel-hashslug
5 results
Select Git revision
Show changes
Commits on Source (7)
......@@ -34,8 +34,12 @@ composer require balping/laravel-hashslug
| Laravel | Hashslug |
|---------|----------|
| 5.4.\* | 1.0.\* |
| 5.5.\* | 1.1.\* |
| 5.4.\* | 2.0.\* |
| 5.5.\* | 2.1.\* |
| 5.6.\* | 2.1.\* |
> **Note:** This package requires either the [BC Math](https://secure.php.net/manual/en/book.bc.php) or [GMP](https://secure.php.net/manual/en/book.gmp.php) extension in order to work.
## Usage
......
......@@ -4,12 +4,12 @@
"keywords": ["laravel", "hashids", "hashid", "slug", "hashslug"],
"type": "library",
"require": {
"hashids/hashids": "^2.0",
"illuminate/database": "5.5.*",
"illuminate/routing": "5.5.*"
"hashids/hashids": "^3.0",
"illuminate/database": "~5.4.0",
"illuminate/routing": "~5.4.0"
},
"require-dev": {
"orchestra/testbench": "3.5.x",
"orchestra/testbench": "^3.4",
"phpunit/phpunit": "^6.3"
},
"license": "GPL-3.0-only",
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
/*
Laravel HashSlug: Package providing a trait to use Hashids on a model
Copyright (C) 2017 Balázs Dura-Kovács
Copyright (C) 2017-2018 Balázs Dura-Kovács
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -98,16 +98,23 @@ trait HasHashSlug {
}
/**
* Used in implicit model binding AND
* used in explicit model binding if no callback
* is specified, eg: Route::model('post', Post::class)
* Terrible hack to make automatic implicit route model binding possible
*
* @param string $slug
* @return \Illuminate\Database\Eloquent\Model
* @see \Illuminate\Routing\RouteBinding@forModel
*
* @param string|array|\Closure $column
* @param string $operator
* @param mixed $value
* @param string $boolean
* @return \Illuminate\Database\Query\Builder
*/
public function resolveRouteBinding($slug){
$id = static::decodeSlug($slug);
return parent::where($this->getKeyName(), $id)->first();
public function where(... $arguments){
if($arguments[0] == 'hashslug'){
$id = static::decodeSlug($arguments[1]);
return parent::where($this->getKeyName(), $id);
}else{
return parent::where(... $arguments);
}
}
/**
......
......@@ -3,7 +3,7 @@
/*
Laravel HashSlug: Package providing a trait to use Hashids on a model
Copyright (C) 2017 Balázs Dura-Kovács
Copyright (C) 2017-2018 Balázs Dura-Kovács
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -32,8 +32,6 @@ use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;
class HashSlugTest extends \Orchestra\Testbench\TestCase
{
use InteractsWithExceptionHandling;
public function setUp() {
parent::setUp();
$this->configureDatabase();
......