コード例 #1
0
ファイル: Users.php プロジェクト: rabbitcms/backend
 /**
  * Controller init.
  * @param Backend $backend
  * @param ViewFactory $view
  */
 public function init(Backend $backend, ViewFactory $view)
 {
     $backend->setActiveMenu('system.users');
     $view->composer($this->viewName('users.form'), function (View $view) {
         $view->with('groups', GroupModel::query()->get());
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('backend_users_groups', function (Blueprint $table) {
         $table->unsignedInteger('user_id');
         $table->unsignedInteger('group_id');
         $table->primary(['user_id', 'group_id']);
         $table->foreign('user_id')->references('id')->on('backend_users')->onDelete('cascade');
         $table->foreign('group_id')->references('id')->on('backend_groups')->onDelete('cascade');
     });
     //Add initial user.
     $group = Group::create(['caption' => 'Administrators', 'permissions' => Backend::getAllAcl()]);
     $user = User::create(['email' => '*****@*****.**', 'password' => 'admin', 'active' => 1]);
     $user->groups()->attach($group);
 }
コード例 #3
0
ファイル: Groups.php プロジェクト: rabbitcms/backend
 /**
  * @param $group_id
  * @param $user_id
  * @Permissions("system.users.write")
  */
 public function destroyUser($group_id, $user_id)
 {
     /**
      * @var GroupModel $group
      */
     $group = GroupModel::query()->findOrFail($group_id);
     $group->users()->detach($user_id);
 }