mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
Use new migration helper
This commit is contained in:
parent
0e470a91da
commit
1f258c362a
|
@ -9,23 +9,9 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
$permissionAttributes = [
|
||||
'group_id' => 3, // Default group ID of members
|
||||
'permission' => 'discussion.likePosts',
|
||||
];
|
||||
|
||||
return [
|
||||
'up' => function (ConnectionInterface $db) use ($permissionAttributes) {
|
||||
$instance = $db->table('permissions')->where($permissionAttributes)->first();
|
||||
|
||||
if (is_null($instance)) {
|
||||
$db->table('permissions')->insert($permissionAttributes);
|
||||
}
|
||||
},
|
||||
|
||||
'down' => function (ConnectionInterface $db) use ($permissionAttributes) {
|
||||
$db->table('permissions')->where($permissionAttributes)->delete();
|
||||
}
|
||||
];
|
||||
return Migration::addPermissions([
|
||||
'discussion.likePosts' => Group::MEMBER_ID
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user