1. Go to this page and download the library: Download laravel-gtm/snowflake-sdk 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/ */
use Illuminate\Database\Eloquent\Model;
use LaravelGtm\SnowflakeSdk\Eloquent\Concerns\UsesSnowflake;
class User extends Model
{
use UsesSnowflake;
protected $connection = 'snowflake';
protected $table = 'users';
}
use Illuminate\Database\Migrations\Migration;
use LaravelGtm\SnowflakeSdk\Schema\SnowflakeBlueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
protected $connection = 'snowflake';
public function up(): void
{
Schema::connection('snowflake')->create('users', function (SnowflakeBlueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->variant('preferences');
$table->timestamps();
$table->clusterBy(['created_at', 'id']);
});
}
public function down(): void
{
Schema::connection('snowflake')->dropIfExists('users');
}
};
use LaravelGtm\SnowflakeSdk\Casts\VariantCast;
use LaravelGtm\SnowflakeSdk\Casts\SnowflakeTimestamp;
class Event extends Model
{
use UsesSnowflake;
protected $connection = 'snowflake';
protected $casts = [
'payload' => VariantCast::class,
'occurred_at' => SnowflakeTimestamp::class,
];
}