Skip to content

Commit

Permalink
Added soft deleting to Backend User Groups (#972)
Browse files Browse the repository at this point in the history
Fixes #386. Related: wintercms/storm#156 PR
  • Loading branch information
arvislacis authored Oct 19, 2023
1 parent 8f7c656 commit 2ba6a1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Winter\Storm\Database\Schema\Blueprint;
use Winter\Storm\Database\Updates\Migration;

class DbBackendAddUsersGroupsDeleteAt extends Migration
{
public function up()
{
if (!Schema::hasColumn('backend_users_groups', 'deleted_at')) {
Schema::table('backend_users_groups', function (Blueprint $table) {
$table->timestamp('deleted_at')->nullable()->after('user_group_id');
});
}
}

public function down()
{
if (Schema::hasColumn('backend_users_groups', 'deleted_at')) {
Schema::table('backend_users_groups', function (Blueprint $table) {
$table->dropColumn('deleted_at');
});
}
}
}
2 changes: 1 addition & 1 deletion modules/backend/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class User extends UserBase
* Relations
*/
public $belongsToMany = [
'groups' => [UserGroup::class, 'table' => 'backend_users_groups']
'groups' => [UserGroup::class, 'table' => 'backend_users_groups', 'softDelete' => true]
];

public $belongsTo = [
Expand Down

0 comments on commit 2ba6a1c

Please sign in to comment.