-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14344 from snipe/features/added_created_by_to_groups
Added created_by to groups table
- Loading branch information
Showing
6 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,18 @@ public function users() | |
return $this->belongsToMany(\App\Models\User::class, 'users_groups'); | ||
} | ||
|
||
/** | ||
* Get the user that created the group | ||
* | ||
* @author A. Gianotto <[email protected]> | ||
* @since [v6.3.0] | ||
* @return \Illuminate\Database\Eloquent\Relations\Relation | ||
*/ | ||
public function admin() | ||
{ | ||
return $this->belongsTo(\App\Models\User::class, 'created_by'); | ||
} | ||
|
||
/** | ||
* Decode JSON permissions into array | ||
* | ||
|
34 changes: 34 additions & 0 deletions
34
database/migrations/2024_02_28_080016_add_created_by_to_permission_groups.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class AddCreatedByToPermissionGroups extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('permission_groups', function (Blueprint $table) { | ||
$table->integer('created_by')->nullable()->default(null); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('permission_groups', function (Blueprint $table) { | ||
if (Schema::hasColumn('permission_groups', 'created_by')) { | ||
$table->dropColumn('created_by'); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters