Code Monkey home page Code Monkey logo

laravel-hashslug's People

Contributors

balping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-hashslug's Issues

Laravel version

I can't get version 1.0.3, cause in one of last commits this branch starts requires illuminate/database 5.5.* . It is possible to get version 1.0.3 with latest bug fixes (invalid slug) or this package don't support laravel 5.4 anymore?
- balping/laravel-hashslug 1.0.3 requires illuminate/database 5.5.* -> satisfiable by illuminate/database[5.5.x-dev] but these conflict with your requirements or minimum-stability

Return slug by Controller

I have a second question. I'm building API based on Laravel and I would like to return objects with hashed slug instead id. How can I do it?

data : {
    id: 'H4sh3dSlu9',
    email: '[email protected]',
    created_at: '...',
    updated_at: '...',
}

Enabling / Disabling

Hey,

It would be super awesome to disable the package in development. If I would have an option in the config with "enabled" or so I can debug much better. I don't know a quick hack for this because you can not include traits dynamically in PHP. Is there an exact code line where a quick and dirty "return" disables the whole package?

Getting Error

I added use HasHashSlug; to my Task model. I can see hashids being generated fine in urls, however when I go to edit page of the model, it gives error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'hashslug' in 'where clause' (SQL: select * from `tasks` where `hashslug` = Eby7m limit 1)

I am using implicit model binding.

Can you please tell what I am missing here other than adding use HasHashSlug; to my model ?

Soft deleted models return 404

The current implementation uses:

/**
	 * Used in implicit model binding AND
	 * used in explicit model binding if no callback
	 * is specified, eg: Route::model('post', Post::class)
	 * 
	 * @param  string $slug
	 * @return \Illuminate\Database\Eloquent\Model
	 */
    public function resolveRouteBinding($slug){
        $id = static::decodeSlug($slug);
        return parent::where($this->getKeyName(), $id)->first();
    }

However, this results in a 404 error being thrown when we're attempting to view/restore a soft-deleted model. The following fixes this by adding withTrashed() to the query:

/**
	 * Used in implicit model binding AND
	 * used in explicit model binding if no callback
	 * is specified, eg: Route::model('post', Post::class)
	 * 
	 * @param  string $slug
	 * @return \Illuminate\Database\Eloquent\Model
	 */
    public function resolveRouteBinding($slug){
        $id = static::decodeSlug($slug);
        return parent::withTrashed()->where($this->getKeyName(), $id)->first();
    }

Accessor

Hey,

Really cool package!
But I miss a custom accessor for the slug.
Look at this example: Model::all()->pluck('name', 'slug');
I won't work. Because slug is just a function. I modified your package and added

public function getHashidAttribute() {
    return $this->slug();
}

With that I can simply Model::all()->pluck('name', 'hashid');
What do you think about it?

Slug length in config

Hey! Is it possible to set $minSlugLength in config file? I want to use it in multiple models and don't want to define it each time.

For example:

return [
    'appsalt' => 'your-application-salt',
    'length' => 8,
    'alphabet' => 'abcdefghijklmnopqrstuvwxyz',
];

Coudl you add this feature?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.