Model fixing, moving things around to improve code.
Adds unique UUID generator, moves functions into repositories for adding servers and users, cleans up code, adding more comments.
This commit is contained in:
parent
01eaeaf178
commit
22b0bbf6ce
8 changed files with 333 additions and 250 deletions
44
app/Repositories/UserRepository.php
Normal file
44
app/Repositories/UserRepository.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Hash;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
class UserRepository
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a user on the panel. Returns the created user's ID.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $email
|
||||
* @param string $password An unhashed version of the user's password.
|
||||
* @return integer
|
||||
*/
|
||||
public function create($username, $email, $password)
|
||||
{
|
||||
|
||||
$user = new User;
|
||||
$uuid = new UuidService;
|
||||
|
||||
$user->uuid = $uuid->table('users')->generate();
|
||||
|
||||
$user->username = $username;
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($password);
|
||||
|
||||
$user->save();
|
||||
|
||||
return $user->id;
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue