PHP code example of mingalevme / illuminate-uqueue

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

    

mingalevme / illuminate-uqueue example snippets


 // /src/migrations/2017_01_01_000002_jobs_add_uniqueable.php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class JobsAddUniqueable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasColumn('jobs', 'unique_id')) {
            Schema::table('jobs', function($table) {
                $table->string('unique_id')->nullable();
                $table->unique(['queue', 'unique_id'], 'jobs_queue_unique_id_unique');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumn('jobs', 'unique_id')) {
            Schema::table('jobs', function (Blueprint $table) {
                $table->dropUnique('jobs_queue_unique_id_unique');
                $table->dropColumn('unique_id');
            });
        }
    }
}




namespace App\Jobs;

use Mingalevme\Illuminate\UQueue\Jobs\Uniqueable;

class ExampleJob implements Uniqueable
{
    protected $data;
    
    public function __construct(array $data)
    {
        ksort($data);
        $this->data = $data;
    }
    
    public function uniqueable()
    {
        return md5(json_encode($this->data));
    }
    
    public function handle()
    {
        // ...
    }
}