diff --git a/database/migrations/2024_10_05_create_htmlable_documents_table.php b/database/migrations/2024_10_05_create_htmlable_documents_table.php index f8423bc..5272852 100644 --- a/database/migrations/2024_10_05_create_htmlable_documents_table.php +++ b/database/migrations/2024_10_05_create_htmlable_documents_table.php @@ -9,12 +9,6 @@ { public function up() { - Schema::create(Document::TABLE_NAME->value, function (Blueprint $table) { - $table->id(); - $table->morphs('model'); - $table->string('name')->unique(); - $table->text('doctype')->nullable(); - $table->timestamps(); - }); + Schema::create(Document::TABLE_NAME->value, fn (Blueprint $table) => Document::toTable($table)); } }; diff --git a/src/Actions/RegisterRoutes.php b/src/Actions/RegisterRoutes.php index fe7c057..88a4db7 100644 --- a/src/Actions/RegisterRoutes.php +++ b/src/Actions/RegisterRoutes.php @@ -16,12 +16,10 @@ class RegisterRoutes public function __invoke() { Route::resource('/htmlable/documents', DocumentsController::class); - Route::get('/htmlable/documents/{document}/render', RenderDocumentController::class); Route::get('/htmlable/documents/{document}/download', DownloadDocumentController::class); Route::resource('/htmlable/elements', ElementsController::class); - Route::get('/htmlable/elements/{element}/render', RenderElementController::class); Route::resource('/htmlable/values', ValuesController::class); diff --git a/src/Enums/Tables/Document.php b/src/Enums/Tables/Document.php index 8e41d68..4dfabe1 100644 --- a/src/Enums/Tables/Document.php +++ b/src/Enums/Tables/Document.php @@ -2,7 +2,20 @@ namespace JamesDordoy\HTMLable\Enums\Tables; +use Illuminate\Database\Schema\Blueprint; + enum Document: string { case TABLE_NAME = 'documents'; + + public static function toTable(Blueprint $table): callable + { + return function() use ($table) { + $table->id(); + $table->morphs('model'); + $table->string('name')->unique(); + $table->text('doctype')->nullable(); + $table->timestamps(); + }; + } } diff --git a/src/Enums/Tables/Element.php b/src/Enums/Tables/Element.php index e69de29..ba6d37c 100644 --- a/src/Enums/Tables/Element.php +++ b/src/Enums/Tables/Element.php @@ -0,0 +1,8 @@ + $this->collection, + ]; + } +}