PHP code example of pderas / shambles

1. Go to this page and download the library: Download pderas/shambles 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/ */

    

pderas / shambles example snippets


Pderas\Shambles\ShamblesServiceProvider::class,

class MyMigration extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('my_table', function(Blueprint $table) {
            $table->string('hash')->unique();
        });
    }
}

use Pderas\Shambles\Traits\ShamblesTrait;

class MyModel extends Model
{
    use ShamblesTrait;

    $defaultHashSize = 36;      // hash length can be set on a per model basis
    $defaultRouteKey = 'hash';  // route key can be set on a per model basis (laravel default is 'id', shambles default is 'hash') 

    ...
}

function myModelRouteFn(Request $request, MyModel $my_model)
{
    ...
    $my_model->update(...);
    ...
}
bash
php artisan vendor:publish --provider="Pderas\Shambles\ShamblesServiceProvider"