mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Fix for #185
This commit is contained in:
45
app/Repositories/User/UserRepository.php
Normal file
45
app/Repositories/User/UserRepository.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* UserRepository.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Repositories\User;
|
||||
|
||||
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Class UserRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\User
|
||||
*/
|
||||
class UserRepository implements UserRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function attachRole(User $user, string $role): bool
|
||||
{
|
||||
$admin = Role::where('name', 'owner')->first();
|
||||
$user->attachRole($admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return User::count();
|
||||
}
|
||||
}
|
34
app/Repositories/User/UserRepositoryInterface.php
Normal file
34
app/Repositories/User/UserRepositoryInterface.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* UserRepositoryInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Repositories\User;
|
||||
|
||||
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Interface UserRepositoryInterface
|
||||
*
|
||||
* @package FireflyIII\Repositories\User
|
||||
*/
|
||||
interface UserRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function attachRole(User $user, string $role): bool;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int;
|
||||
}
|
Reference in New Issue
Block a user