PHP code example of netsells / hash-model-ids

1. Go to this page and download the library: Download netsells/hash-model-ids library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

netsells / hash-model-ids example snippets


use Netsells\HashModelIds\HashesModelIdsTrait;

class Model extends BaseModel
{
    use HashesModelIdsTrait;
}

    Route::get('models/{model}', function (Model $model) {
        return $model;
    });

    
    $url = url("models/$model->hashed_id");
    

    public function rules()
    {
        return [
            'hashed_id' => [
                ExistsWithHashedIdRule::make(Model::class)
                    ->where(function ($query) {
                        $query->where('type', 'test');
                    })
                    ->where('foo', 'bar'),
            ],
        ];
    }