Exemple #1
0
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($tag) {
         $tag->discussions()->detach();
         Permission::where('permission', 'like', "tag{$tag->id}.%")->delete();
     });
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function render(Request $request, array $routeParams = [])
 {
     $view = parent::render($request, $routeParams);
     $view->setVariable('config', $this->settings->all());
     $view->setVariable('permissions', Permission::map());
     $view->setVariable('extensions', app('flarum.extensions')->getInfo());
     return $view;
 }
 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, array $routeParams = [])
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $permission = $request->get('permission');
     $groupIds = $request->get('groupIds');
     Permission::where('permission', $permission)->delete();
     Permission::insert(array_map(function ($groupId) use($permission) {
         return ['permission' => $permission, 'group_id' => $groupId];
     }, $groupIds));
     return new EmptyResponse(204);
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Permission::where($this->getPermissionAttributes())->delete();
 }
 protected function seedPermissions()
 {
     $permissions = [[2, 'forum.view'], [3, 'forum.startDiscussion'], [3, 'discussion.reply'], [4, 'discussion.delete'], [4, 'discussion.deletePosts'], [4, 'discussion.editPosts'], [4, 'discussion.rename']];
     foreach ($permissions as &$permission) {
         $permission = ['group_id' => $permission[0], 'permission' => $permission[1]];
     }
     Permission::insert($permissions);
 }