Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uuid models support #2310

Open
wants to merge 10 commits into
base: 3.x
Choose a base branch
from
1 change: 1 addition & 0 deletions config/enabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
'users-2fa' => false,
'users-oauth' => false,
'permissions-management' => false,
'uuid-models-key-support' => false,
];
1 change: 1 addition & 0 deletions docs/content/1_docs/2_getting-started/3_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ return [
'users-2fa' => false,
'users-oauth' => false,
'permissions-management' => false,
'uuid-models-key-support' => false,
],
];
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$connection = Schema::connection(config('activitylog.database_connection'));
$tableName = config('activitylog.table_name');

if ($connection->hasTable($tableName)) {
$connection->table(
$tableName,
function (Blueprint $table) use ($connection, $tableName) {
if ($connection->hasColumn($tableName, 'subject_id')) {
$table->string('subject_id', 36)->change();
}
}
);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$connection = Schema::connection(config('activitylog.database_connection'));
$tableName = config('activitylog.table_name');

if ($connection->hasTable($tableName)) {
$connection->table(
$tableName,
function (Blueprint $table) use ($connection, $tableName) {
if ($connection->hasColumn($tableName, 'subject_id')) {
$table->bigInteger('subject_id')->change();
}
}
);
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$tableName = config('twill.mediables_table', 'twill_mediables');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'mediable_id')) {
$table->string('mediable_id', 36)->change();
}
});
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
$tableName = config('twill.mediables_table', 'twill_mediables');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'mediable_id')) {
$table->bigInteger('mediable_id')->change();
}
});
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$tableName = config('twill.fileables_table', 'twill_fileables');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'fileable_id')) {
$table->string('fileable_id', 36)->change();
}
});
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
$tableName = config('twill.fileables_table', 'twill_fileables');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'fileable_id')) {
$table->bigInteger('fileable_id')->change();
}
});
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$tableName = config('twill.related_table', 'twill_related');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'subject_id')) {
$table->string('subject_id', 36)->change();
}
if (Schema::hasColumn($tableName, 'related_id')) {
$table->string('related_id', 36)->change();
}
});
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
$tableName = config('twill.related_table', 'twill_related');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'subject_id')) {
$table->bigInteger('subject_id')->change();
}
if (Schema::hasColumn($tableName, 'related_id')) {
$table->bigInteger('related_id')->change();
}
});
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$tableName = config('twill.blocks_table', 'twill_blocks');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'blockable_id')) {
$table->string('blockable_id', 36)->change();
}
});
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
$tableName = config('twill.blocks_table', 'twill_blocks');
if (Schema::hasTable($tableName)) {
Schema::table($tableName, function (Blueprint $table) use ($tableName) {
if (Schema::hasColumn($tableName, 'blockable_id')) {
$table->bigInteger('blockable_id')->change();
}
});
}
}
};
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUpController(): void
}
}

public function update(int|TwillModelContract $id, ?int $submoduleId = null): JsonResponse
public function update(int|string|TwillModelContract $id, int|string|null $submoduleId = null): JsonResponse
{
$model = AppSetting::findOrFail($id);

Expand Down Expand Up @@ -107,7 +107,7 @@ protected function getRepositoryClass($model): string
return AppSettingsRepository::class;
}

protected function form(?int $id, ?TwillModelContract $item = null): array
protected function form(int|string|null $id, ?TwillModelContract $item = null): array
{
$base = parent::form($id, $item);

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/FileLibraryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function filters(): TableFilters
]);
}

public function index(?int $parentModuleId = null): mixed
public function index(int|string|null $parentModuleId = null): mixed
{
if ($this->request->has('except')) {
$prependScope['exceptIds'] = $this->request->get('except');
Expand Down Expand Up @@ -172,7 +172,7 @@ protected function getRequestFilters(): array
}

/**
* @param int|null $parentModuleId
* @param int|string|null $parentModuleId
* @return JsonResponse
* @throws BindingResolutionException
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ protected function getBrowserItems($scopes = [])
})->values();
}

public function edit(int|TwillModelContract $id): mixed
public function edit(int|string|TwillModelContract $id): mixed
{
$this->authorizableOptions['edit'] = 'edit-group';

return parent::edit($id);
}

public function update(int|TwillModelContract $id, ?int $submoduleId = null): JsonResponse
public function update(int|string|TwillModelContract $id, int|string|null $submoduleId = null): JsonResponse
{
$this->authorizableOptions['edit'] = 'edit-group';

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/MediaLibraryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function filters(): TableFilters
]);
}

public function index(?int $parentModuleId = null): array
public function index(int|string|null $parentModuleId = null): array
{
if ($this->request->has('except')) {
$prependScope['exceptIds'] = $this->request->get('except');
Expand Down Expand Up @@ -150,7 +150,7 @@ protected function getRequestFilters(): array
}

/**
* @param int|null $parentModuleId
* @param int|string|null $parentModuleId
* @return
*/
public function store($parentModuleId = null)
Expand Down
Loading
Loading