Skip to content

Commit 0d83be2

Browse files
committed
wip
1 parent 8e0eadb commit 0d83be2

31 files changed

+1700
-824
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Illuminate\Support\Str;
7+
use App\Models\Venue;
8+
9+
class BpmnFactory extends Factory
10+
{
11+
/**
12+
* The name of the factory's corresponding model.
13+
*
14+
* @var string
15+
*/
16+
protected $model = Conference::class;
17+
18+
/**
19+
* Define the model's default state.
20+
*/
21+
public function definition(): array
22+
{
23+
return [
24+
'title' => fake()->title(),
25+
'description' => fake()->text(),
26+
27+
'status' => fake()->word(),
28+
29+
'bpmn_id' => null,
30+
];
31+
}
32+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Illuminate\Support\Facades\Hash;
7+
use Illuminate\Support\Str;
8+
9+
/**
10+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
11+
*/
12+
class UserFactory extends Factory
13+
{
14+
/**
15+
* The current password being used by the factory.
16+
*/
17+
protected static ?string $password;
18+
19+
/**
20+
* Define the model's default state.
21+
*
22+
* @return array<string, mixed>
23+
*/
24+
public function definition(): array
25+
{
26+
return [
27+
'name' => fake()->name(),
28+
'email' => fake()->unique()->safeEmail(),
29+
'email_verified_at' => now(),
30+
'password' => static::$password ??= Hash::make('password'),
31+
'remember_token' => Str::random(10),
32+
];
33+
}
34+
35+
/**
36+
* Indicate that the model's email address should be unverified.
37+
*/
38+
public function unverified(): static
39+
{
40+
return $this->state(fn (array $attributes) => [
41+
'email_verified_at' => null,
42+
]);
43+
}
44+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('bpmns', function (Blueprint $table) {
15+
$table->id();
16+
$table->string('title', 60);
17+
$table->text('description')->nullable();
18+
$table->boolean('is_published')->default(false);
19+
$table->string('status');
20+
$table->timestamps();
21+
$table->longText('bpmn_xml')->nullable();
22+
$table->longText('bpmn_svg')->nullable();
23+
});
24+
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*/
30+
public function down(): void
31+
{
32+
Schema::dropIfExists('bpmns');
33+
}
34+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table('bpmns', function (Blueprint $table) {
12+
$table->foreignId('bpmn_media')
13+
->nullable()
14+
->constrained('media')
15+
->nullOnDelete()
16+
->after('title');
17+
});
18+
}
19+
20+
public function down(): void
21+
{
22+
Schema::table('bpmns', function (Blueprint $table) {
23+
$table->dropForeign(['bpmn_media']);
24+
$table->dropColumn('bpmn_media');
25+
});
26+
}
27+
};
28+

packages/bpmn/src/BpmnPlugin.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Moox\Bpmn;
4+
5+
use Filament\Panel;
6+
use Filament\Contracts\Plugin;
7+
use Moox\Bpmn\Resources\Bpmns\BpmnResource;
8+
use Filament\Support\Concerns\EvaluatesClosures;
9+
10+
class BpmnPlugin implements Plugin
11+
{
12+
use EvaluatesClosures;
13+
14+
public function getId(): string
15+
{
16+
return 'bpmn';
17+
}
18+
19+
public function register(Panel $panel): void
20+
{
21+
$panel->resources([
22+
BpmnResource::class,
23+
]);
24+
}
25+
26+
public function boot(Panel $panel): void
27+
{
28+
//
29+
}
30+
31+
public static function make(): static
32+
{
33+
return app(static::class);
34+
}
35+
}

packages/bpmn/src/Models/Bpmn.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Spatie\MediaLibrary\HasMedia;
8+
use Spatie\MediaLibrary\InteractsWithMedia;
9+
use Moox\Media\Models\Media;
10+
use Moox\Media\Models\MediaUsable;
11+
12+
class Bpmn extends Model implements HasMedia
13+
{
14+
use HasFactory;
15+
use InteractsWithMedia;
16+
17+
protected $fillable = [
18+
'title',
19+
'description',
20+
'is_published',
21+
'status',
22+
'bpmn_xml',
23+
'bpmn_svg',
24+
'bpmn_media',
25+
];
26+
27+
protected function casts(): array
28+
{
29+
return [
30+
'id' => 'integer',
31+
'is_published' => 'boolean',
32+
'bpmn_media' => 'array',
33+
];
34+
}
35+
36+
/**
37+
* Media attached via the media_usables pivot.
38+
*/
39+
public function mediaThroughUsables()
40+
{
41+
return $this->morphToMany(Media::class, 'media_usable')
42+
->using(MediaUsable::class)
43+
->withTimestamps();
44+
}
45+
}

packages/bpmn/src/Models/User.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Models;
4+
5+
// use Illuminate\Contracts\Auth\MustVerifyEmail;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Foundation\Auth\User as Authenticatable;
8+
use Illuminate\Notifications\Notifiable;
9+
10+
class User extends Authenticatable
11+
{
12+
/** @use HasFactory<\Database\Factories\UserFactory> */
13+
use HasFactory, Notifiable;
14+
15+
/**
16+
* The attributes that are mass assignable.
17+
*
18+
* @var list<string>
19+
*/
20+
protected $fillable = [
21+
'name',
22+
'email',
23+
'password',
24+
];
25+
26+
/**
27+
* The attributes that should be hidden for serialization.
28+
*
29+
* @var list<string>
30+
*/
31+
protected $hidden = [
32+
'password',
33+
'remember_token',
34+
];
35+
36+
/**
37+
* Get the attributes that should be cast.
38+
*
39+
* @return array<string, string>
40+
*/
41+
protected function casts(): array
42+
{
43+
return [
44+
'email_verified_at' => 'datetime',
45+
'password' => 'hashed',
46+
];
47+
}
48+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Resources\Bpmns;
4+
5+
use BackedEnum;
6+
use Filament\Tables\Table;
7+
use Moox\Bpmn\Models\Bpmn;
8+
use Filament\Schemas\Schema;
9+
use Filament\Resources\Resource;
10+
use Filament\Support\Icons\Heroicon;
11+
use Moox\Bpmn\Resources\Bpmns\Pages\EditBpmn;
12+
use Moox\Bpmn\Resources\Bpmns\Pages\ViewBpmn;
13+
use Moox\Bpmn\Resources\Bpmns\Pages\ListBpmns;
14+
use Moox\Bpmn\Resources\Bpmns\Pages\CreateBpmn;
15+
use Moox\Bpmn\Resources\Bpmns\Schemas\BpmnForm;
16+
use Moox\Bpmn\Resources\Bpmns\Tables\BpmnsTable;
17+
use Moox\Bpmn\Resources\Bpmns\Schemas\BpmnInfolist;
18+
19+
class BpmnResource extends Resource
20+
{
21+
protected static ?string $model = Bpmn::class;
22+
23+
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
24+
25+
protected static ?string $recordTitleAttribute = 'Bpmn';
26+
27+
public static function form(Schema $schema): Schema
28+
{
29+
return BpmnForm::configure($schema);
30+
}
31+
32+
public static function infolist(Schema $schema): Schema
33+
{
34+
return BpmnInfolist::configure($schema);
35+
}
36+
37+
public static function table(Table $table): Table
38+
{
39+
return BpmnsTable::configure($table);
40+
}
41+
42+
public static function getRelations(): array
43+
{
44+
return [
45+
//
46+
];
47+
}
48+
49+
public static function getPages(): array
50+
{
51+
return [
52+
'index' => ListBpmns::route('/'),
53+
'create' => CreateBpmn::route('/create'),
54+
'view' => ViewBpmn::route('/{record}'),
55+
'edit' => EditBpmn::route('/{record}/edit'),
56+
];
57+
}
58+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Resources\Bpmns\Pages;
4+
5+
use Filament\Actions\Action;
6+
use Filament\Resources\Pages\CreateRecord;
7+
use Moox\Bpmn\Resources\Bpmns\BpmnResource;
8+
9+
10+
class CreateBpmn extends CreateRecord
11+
{
12+
13+
14+
protected static string $resource = BpmnResource::class;
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Moox\Bpmn\Resources\Bpmns\Pages;
4+
5+
6+
use Filament\Actions\ViewAction;
7+
use Filament\Actions\DeleteAction;
8+
use Filament\Resources\Pages\EditRecord;
9+
use Moox\Bpmn\Resources\Bpmns\BpmnResource;
10+
11+
class EditBpmn extends EditRecord
12+
{
13+
protected static string $resource = BpmnResource::class;
14+
15+
protected function getHeaderActions(): array
16+
{
17+
return [
18+
ViewAction::make(),
19+
DeleteAction::make(),
20+
];
21+
}
22+
}

0 commit comments

Comments
 (0)