Skip to content

Commit

Permalink
Sync w-i-p
Browse files Browse the repository at this point in the history
  • Loading branch information
adrolli committed Mar 6, 2024
1 parent de1eec9 commit b5b1827
Show file tree
Hide file tree
Showing 11 changed files with 453 additions and 95 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

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

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('platforms', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->string('slug');
$table->string('domain');
$table->boolean('selection')->nullable();
$table->tinyInteger('order')->nullable();
$table->boolean('locked')->nullable();
$table->boolean('master')->nullable();
$table->string('thumbnail')->nullable();
$table->unsignedBigInteger('platformable_id');
$table->string('platformable_type');

$table->index('platformable_id');
$table->index('platformable_type');

$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('platforms');
}
};
44 changes: 44 additions & 0 deletions packages/sync/src/Models/Platform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Moox\Sync\Models;

use Illuminate\Database\Eloquent\Model;

class Platform extends Model
{
protected $fillable = [
'title',
'slug',
'domain',
'selection',
'order',
'locked',
'master',
'thumbnail',
'platformable_id',
'platformable_type',
];

protected $searchableFields = ['*'];

protected $casts = [
'selection' => 'boolean',
'locked' => 'boolean',
'master' => 'boolean',
];

public function sources()
{
return $this->hasMany(Sync::class, 'source_platform_id');
}

public function targets()
{
return $this->hasMany(Sync::class, 'target_platform_id');
}

public function platformable()
{
return $this->morphTo();
}
}
32 changes: 23 additions & 9 deletions packages/sync/src/Models/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@

class Sync extends Model
{
protected $table = 'sync';

protected $fillable = [
'name',
'started_at',
'finished_at',
'failed',
'syncable_id',
'syncable_type',
'source_platform_id',
'target_platform_id',
'last_sync',
];

protected $searchableFields = ['*'];

protected $casts = [
'failed' => 'bool',
'started_at' => 'datetime',
'finished_at' => 'datetime',
'last_sync' => 'datetime',
];

public function sourcePlatform()
{
//return $this->belongsTo(Platform::class, 'source_platform_id');
}

public function targetPlatform()
{
//return $this->belongsTo(Platform::class, 'target_platform_id');
}

public function syncable()
{
return $this->morphTo();
}
}
35 changes: 35 additions & 0 deletions packages/sync/src/PlatformPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Moox\Sync;

use Filament\Contracts\Plugin;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use Moox\Sync\Resources\PlatformResource;

class SyncPlugin implements Plugin
{
use EvaluatesClosures;

public function getId(): string
{
return 'platform';
}

public function register(Panel $panel): void
{
$panel->resources([
PlatformResource::class,
]);
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}
}
Loading

0 comments on commit b5b1827

Please sign in to comment.