@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function checkWords(string $needle): bool |
| 48 | 48 | { |
| 49 | - return count(array_filter(Config::get('chocolatey.invalid'), function ($illegal) use ($needle) { |
|
| 49 | + return count(array_filter(Config::get('chocolatey.invalid'), function($illegal) use ($needle) { |
|
| 50 | 50 | return stripos($needle, $illegal) !== false; |
| 51 | 51 | })) == 0; |
| 52 | 52 | } |
@@ -1,29 +1,29 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Helpers; |
|
| 3 | + namespace App\Helpers; |
|
| 4 | 4 | |
| 5 | -use App\Singleton; |
|
| 6 | -use Illuminate\Support\Facades\Config; |
|
| 5 | + use App\Singleton; |
|
| 6 | + use Illuminate\Support\Facades\Config; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class Validation. |
| 10 | 10 | */ |
| 11 | -final class Validation extends Singleton |
|
| 12 | -{ |
|
| 13 | - /** |
|
| 11 | + final class Validation extends Singleton |
|
| 12 | + { |
|
| 13 | + /** |
|
| 14 | 14 | * Filter an Username from the Invalid Names Base. |
| 15 | 15 | * |
| 16 | 16 | * @param string $username |
| 17 | 17 | * |
| 18 | 18 | * @return bool |
| 19 | 19 | */ |
| 20 | - public function filterUserName(string $username): bool |
|
| 21 | - { |
|
| 22 | - return $this->checkSize($username, 4, 15) && $this->checkWords($username) && |
|
| 23 | - !preg_match('/[^A-Za-z0-9]/', $username); |
|
| 24 | - } |
|
| 20 | + public function filterUserName(string $username): bool |
|
| 21 | + { |
|
| 22 | + return $this->checkSize($username, 4, 15) && $this->checkWords($username) && |
|
| 23 | + !preg_match('/[^A-Za-z0-9]/', $username); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | + /** |
|
| 27 | 27 | * Check String Size. |
| 28 | 28 | * |
| 29 | 29 | * @param string $needle |
@@ -32,22 +32,22 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function checkSize(string $needle, int $min, int $max) |
|
| 36 | - { |
|
| 37 | - return strlen($needle) <= $max && strlen($needle) >= $min; |
|
| 38 | - } |
|
| 35 | + public function checkSize(string $needle, int $min, int $max) |
|
| 36 | + { |
|
| 37 | + return strlen($needle) <= $max && strlen($needle) >= $min; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | + /** |
|
| 41 | 41 | * Check for Illegal Words. |
| 42 | 42 | * |
| 43 | 43 | * @param string $needle |
| 44 | 44 | * |
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | - public function checkWords(string $needle): bool |
|
| 48 | - { |
|
| 49 | - return count(array_filter(Config::get('chocolatey.invalid'), function ($illegal) use ($needle) { |
|
| 50 | - return stripos($needle, $illegal) !== false; |
|
| 51 | - })) == 0; |
|
| 52 | - } |
|
| 47 | + public function checkWords(string $needle): bool |
|
| 48 | + { |
|
| 49 | + return count(array_filter(Config::get('chocolatey.invalid'), function ($illegal) use ($needle) { |
|
| 50 | + return stripos($needle, $illegal) !== false; |
|
| 51 | + })) == 0; |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -75,8 +75,7 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
| 77 | 77 | |
| 78 | - $user = $chocolateyId->last_logged_id == 0 ? UserModel::where('mail', $request->json()->get('email'))->first() : |
|
| 79 | - UserModel::find($chocolateyId->last_logged_id); |
|
| 78 | + $user = $chocolateyId->last_logged_id == 0 ? UserModel::where('mail', $request->json()->get('email'))->first() : UserModel::find($chocolateyId->last_logged_id); |
|
| 80 | 79 | |
| 81 | 80 | $chocolateyId->last_logged_id = $user->uniqueId; |
| 82 | 81 | |
@@ -91,7 +90,7 @@ discard block |
||
| 91 | 90 | */ |
| 92 | 91 | public function hasSession() |
| 93 | 92 | { |
| 94 | - return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 93 | + return (bool)Session::get(Config::get('chocolatey.security.session')); |
|
| 95 | 94 | } |
| 96 | 95 | |
| 97 | 96 | /** |
@@ -1,44 +1,44 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Helpers; |
|
| 3 | + namespace App\Helpers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\Session; |
|
| 6 | -use App\Models\ChocolateyId; |
|
| 7 | -use App\Models\User as UserModel; |
|
| 8 | -use App\Singleton; |
|
| 9 | -use Illuminate\Http\Request; |
|
| 10 | -use Illuminate\Support\Facades\Config; |
|
| 5 | + use App\Facades\Session; |
|
| 6 | + use App\Models\ChocolateyId; |
|
| 7 | + use App\Models\User as UserModel; |
|
| 8 | + use App\Singleton; |
|
| 9 | + use Illuminate\Http\Request; |
|
| 10 | + use Illuminate\Support\Facades\Config; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Class User. |
| 14 | 14 | */ |
| 15 | -final class User extends Singleton |
|
| 16 | -{ |
|
| 17 | - /** |
|
| 15 | + final class User extends Singleton |
|
| 16 | + { |
|
| 17 | + /** |
|
| 18 | 18 | * Update User Data without overwriting Session. |
| 19 | 19 | * |
| 20 | 20 | * @param array $parameters |
| 21 | 21 | * |
| 22 | 22 | * @return UserModel |
| 23 | 23 | */ |
| 24 | - public function updateSession(array $parameters) |
|
| 25 | - { |
|
| 26 | - return $this->setSession($this->updateUser($this->getUser(), $parameters)); |
|
| 27 | - } |
|
| 24 | + public function updateSession(array $parameters) |
|
| 25 | + { |
|
| 26 | + return $this->setSession($this->updateUser($this->getUser(), $parameters)); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | + /** |
|
| 30 | 30 | * Set User Data on Session. |
| 31 | 31 | * |
| 32 | 32 | * @param UserModel $user |
| 33 | 33 | * |
| 34 | 34 | * @return UserModel |
| 35 | 35 | */ |
| 36 | - public function setSession(UserModel $user) |
|
| 37 | - { |
|
| 38 | - return Session::set(Config::get('chocolatey.security.session'), $user); |
|
| 39 | - } |
|
| 36 | + public function setSession(UserModel $user) |
|
| 37 | + { |
|
| 38 | + return Session::set(Config::get('chocolatey.security.session'), $user); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | + /** |
|
| 42 | 42 | * Update User Data by User Model. |
| 43 | 43 | * |
| 44 | 44 | * @param UserModel $user |
@@ -46,59 +46,59 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return UserModel |
| 48 | 48 | */ |
| 49 | - public function updateUser($user, array $parameters) |
|
| 50 | - { |
|
| 51 | - $user->update($parameters); |
|
| 49 | + public function updateUser($user, array $parameters) |
|
| 50 | + { |
|
| 51 | + $user->update($parameters); |
|
| 52 | 52 | |
| 53 | - return $user; |
|
| 54 | - } |
|
| 53 | + return $user; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | + /** |
|
| 57 | 57 | * Get User Data from Session |
| 58 | 58 | * If User Session doesn't exists, return null. |
| 59 | 59 | * |
| 60 | 60 | * @return UserModel|null |
| 61 | 61 | */ |
| 62 | - public function getUser() |
|
| 63 | - { |
|
| 64 | - return Session::get(Config::get('chocolatey.security.session')) ?? null; |
|
| 65 | - } |
|
| 62 | + public function getUser() |
|
| 63 | + { |
|
| 64 | + return Session::get(Config::get('chocolatey.security.session')) ?? null; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | + /** |
|
| 68 | 68 | * Set Session From Login Credentials. |
| 69 | 69 | * |
| 70 | 70 | * @param Request $request |
| 71 | 71 | * |
| 72 | 72 | * @return UserModel |
| 73 | 73 | */ |
| 74 | - public function loginUser(Request $request) |
|
| 75 | - { |
|
| 76 | - $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 74 | + public function loginUser(Request $request) |
|
| 75 | + { |
|
| 76 | + $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 77 | 77 | |
| 78 | - $user = $chocolateyId->last_logged_id == 0 ? UserModel::where('mail', $request->json()->get('email'))->first() : |
|
| 79 | - UserModel::find($chocolateyId->last_logged_id); |
|
| 78 | + $user = $chocolateyId->last_logged_id == 0 ? UserModel::where('mail', $request->json()->get('email'))->first() : |
|
| 79 | + UserModel::find($chocolateyId->last_logged_id); |
|
| 80 | 80 | |
| 81 | - $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 81 | + $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 82 | 82 | |
| 83 | - return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 84 | - ? $this->setSession($user) : null; |
|
| 85 | - } |
|
| 83 | + return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 84 | + ? $this->setSession($user) : null; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | + /** |
|
| 88 | 88 | * Return if USer Session Exists. |
| 89 | 89 | * |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function hasSession() |
|
| 93 | - { |
|
| 94 | - return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 95 | - } |
|
| 92 | + public function hasSession() |
|
| 93 | + { |
|
| 94 | + return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | + /** |
|
| 98 | 98 | * Erase User Session. |
| 99 | 99 | */ |
| 100 | - public function eraseSession() |
|
| 101 | - { |
|
| 102 | - Session::erase(Config::get('chocolatey.security.session')); |
|
| 103 | - } |
|
| 100 | + public function eraseSession() |
|
| 101 | + { |
|
| 102 | + Session::erase(Config::get('chocolatey.security.session')); |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -1,41 +1,41 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Helpers; |
|
| 3 | + namespace App\Helpers; |
|
| 4 | 4 | |
| 5 | -use App\Singleton; |
|
| 5 | + use App\Singleton; |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Class Session. |
| 9 | 9 | */ |
| 10 | -final class Session extends Singleton |
|
| 11 | -{ |
|
| 12 | - /** |
|
| 10 | + final class Session extends Singleton |
|
| 11 | + { |
|
| 12 | + /** |
|
| 13 | 13 | * Rename the Session ID. |
| 14 | 14 | * |
| 15 | 15 | * @param string $name |
| 16 | 16 | */ |
| 17 | - public function rename($name) |
|
| 18 | - { |
|
| 19 | - session_name($name); |
|
| 20 | - } |
|
| 17 | + public function rename($name) |
|
| 18 | + { |
|
| 19 | + session_name($name); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | + /** |
|
| 23 | 23 | * Start Session Handler. |
| 24 | 24 | */ |
| 25 | - public function start() |
|
| 26 | - { |
|
| 27 | - session_start(); |
|
| 28 | - } |
|
| 25 | + public function start() |
|
| 26 | + { |
|
| 27 | + session_start(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | + /** |
|
| 31 | 31 | * Stop Session Handler. |
| 32 | 32 | */ |
| 33 | - public function destroy() |
|
| 34 | - { |
|
| 35 | - session_destroy(); |
|
| 36 | - } |
|
| 33 | + public function destroy() |
|
| 34 | + { |
|
| 35 | + session_destroy(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Store a Variable in the Session. |
| 40 | 40 | * |
| 41 | 41 | * @param string $key |
@@ -43,46 +43,46 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return mixed |
| 45 | 45 | */ |
| 46 | - public function set($key, $value) |
|
| 47 | - { |
|
| 48 | - $_SESSION[$key] = $value; |
|
| 46 | + public function set($key, $value) |
|
| 47 | + { |
|
| 48 | + $_SESSION[$key] = $value; |
|
| 49 | 49 | |
| 50 | - return $value; |
|
| 51 | - } |
|
| 50 | + return $value; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | + /** |
|
| 54 | 54 | * Get a Attribute Value from Session. |
| 55 | 55 | * |
| 56 | 56 | * @param string $key |
| 57 | 57 | * |
| 58 | 58 | * @return mixed |
| 59 | 59 | */ |
| 60 | - public function get($key) |
|
| 61 | - { |
|
| 62 | - return $this->has($key) ? $_SESSION[$key] : null; |
|
| 63 | - } |
|
| 60 | + public function get($key) |
|
| 61 | + { |
|
| 62 | + return $this->has($key) ? $_SESSION[$key] : null; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 65 | + /** |
|
| 66 | 66 | * Check if a Key exists in the Session. |
| 67 | 67 | * |
| 68 | 68 | * @param mixed $key |
| 69 | 69 | * |
| 70 | 70 | * @return bool |
| 71 | 71 | */ |
| 72 | - public function has($key) |
|
| 73 | - { |
|
| 74 | - return array_key_exists($key, $_SESSION); |
|
| 75 | - } |
|
| 72 | + public function has($key) |
|
| 73 | + { |
|
| 74 | + return array_key_exists($key, $_SESSION); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 77 | + /** |
|
| 78 | 78 | * Erase a Attribute from Session. |
| 79 | 79 | * |
| 80 | 80 | * @param string $key |
| 81 | 81 | */ |
| 82 | - public function erase($key) |
|
| 83 | - { |
|
| 84 | - $_SESSION[$key] = null; |
|
| 82 | + public function erase($key) |
|
| 83 | + { |
|
| 84 | + $_SESSION[$key] = null; |
|
| 85 | 85 | |
| 86 | - unset($_SESSION[$key]); |
|
| 87 | - } |
|
| 86 | + unset($_SESSION[$key]); |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class Ban. |
| 7 | 7 | */ |
| 8 | -class Ban extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class Ban extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'bans'; |
|
| 22 | + protected $table = 'bans'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Store an User Ban. |
| 33 | 33 | * |
| 34 | 34 | * @param int $userId |
@@ -41,29 +41,29 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return Ban |
| 43 | 43 | */ |
| 44 | - public function store(int $userId, int $userStaffId, string $banReason, $banType = 'account', $banExpire = 0, $ipAddress = '', $machineId = ''): Ban |
|
| 45 | - { |
|
| 46 | - $this->attributes['user_id'] = $userId; |
|
| 47 | - $this->attributes['user_staff_id'] = $userStaffId; |
|
| 48 | - $this->attributes['ban_reason'] = $banReason; |
|
| 49 | - $this->attributes['ban_expire'] = $banExpire; |
|
| 50 | - $this->attributes['timestamp'] = time(); |
|
| 51 | - $this->attributes['ip'] = $ipAddress; |
|
| 52 | - $this->attributes['type'] = $banType; |
|
| 53 | - $this->attributes['machine_id'] = $machineId; |
|
| 44 | + public function store(int $userId, int $userStaffId, string $banReason, $banType = 'account', $banExpire = 0, $ipAddress = '', $machineId = ''): Ban |
|
| 45 | + { |
|
| 46 | + $this->attributes['user_id'] = $userId; |
|
| 47 | + $this->attributes['user_staff_id'] = $userStaffId; |
|
| 48 | + $this->attributes['ban_reason'] = $banReason; |
|
| 49 | + $this->attributes['ban_expire'] = $banExpire; |
|
| 50 | + $this->attributes['timestamp'] = time(); |
|
| 51 | + $this->attributes['ip'] = $ipAddress; |
|
| 52 | + $this->attributes['type'] = $banType; |
|
| 53 | + $this->attributes['machine_id'] = $machineId; |
|
| 54 | 54 | |
| 55 | - $this->save(); |
|
| 55 | + $this->save(); |
|
| 56 | 56 | |
| 57 | - return $this; |
|
| 58 | - } |
|
| 57 | + return $this; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | + /** |
|
| 61 | 61 | * Get Ban Expire Attribute. |
| 62 | 62 | * |
| 63 | 63 | * @return string |
| 64 | 64 | */ |
| 65 | - public function getBanExpireAttribute(): string |
|
| 66 | - { |
|
| 67 | - return date('M/d/Y h:m A', $this->attributes['ban_expire']); |
|
| 68 | - } |
|
| 65 | + public function getBanExpireAttribute(): string |
|
| 66 | + { |
|
| 67 | + return date('M/d/Y h:m A', $this->attributes['ban_expire']); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -1,52 +1,52 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class NuxValidation. |
| 7 | 7 | */ |
| 8 | -class NuxValidation |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class NuxValidation |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Result Code. |
| 12 | 12 | * |
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - public $code; |
|
| 15 | + public $code; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Specification of what Happened. |
| 19 | 19 | * |
| 20 | 20 | * @var array|null |
| 21 | 21 | */ |
| 22 | - public $validationResult = null; |
|
| 22 | + public $validationResult = null; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Username Suggestions. |
| 26 | 26 | * |
| 27 | 27 | * @TODO: Code Suggestions |
| 28 | 28 | * |
| 29 | 29 | * @var array|null |
| 30 | 30 | */ |
| 31 | - public $suggestions = []; |
|
| 31 | + public $suggestions = []; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | + /** |
|
| 34 | 34 | * Create a NUX Validation. |
| 35 | 35 | * |
| 36 | 36 | * @param string $code |
| 37 | 37 | * @param array $validationResult |
| 38 | 38 | * @param array $suggestions |
| 39 | 39 | */ |
| 40 | - public function __construct(string $code = 'OK', array $validationResult = [], array $suggestions = []) |
|
| 41 | - { |
|
| 42 | - $this->code = $code; |
|
| 40 | + public function __construct(string $code = 'OK', array $validationResult = [], array $suggestions = []) |
|
| 41 | + { |
|
| 42 | + $this->code = $code; |
|
| 43 | 43 | |
| 44 | - if (!empty($validationResult)) { |
|
| 45 | - $this->validationResult = $validationResult; |
|
| 46 | - } |
|
| 44 | + if (!empty($validationResult)) { |
|
| 45 | + $this->validationResult = $validationResult; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - if (!empty($suggestions)) { |
|
| 49 | - $this->suggestions = $suggestions; |
|
| 50 | - } |
|
| 51 | - } |
|
| 48 | + if (!empty($suggestions)) { |
|
| 49 | + $this->suggestions = $suggestions; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class RoomItem. |
| 7 | 7 | */ |
| 8 | -class RoomItem extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class RoomItem extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'items'; |
|
| 22 | + protected $table = 'items'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Store a RoomItem. |
| 33 | 33 | * |
| 34 | 34 | * @param int $userId |
@@ -43,23 +43,23 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return RoomItem |
| 45 | 45 | */ |
| 46 | - public function store(int $userId, int $roomId, int $itemId, int $xPosition, int $yPosition, string $zPosition, int $rotation, string $extraData, string $wallPosition = ''): RoomItem |
|
| 47 | - { |
|
| 48 | - $this->attributes['user_id'] = $userId; |
|
| 49 | - $this->attributes['room_id'] = $roomId; |
|
| 50 | - $this->attributes['item_id'] = $itemId; |
|
| 51 | - $this->attributes['x'] = $xPosition; |
|
| 52 | - $this->attributes['y'] = $yPosition; |
|
| 53 | - $this->attributes['z'] = $zPosition; |
|
| 54 | - $this->attributes['rot'] = $rotation; |
|
| 55 | - $this->attributes['extra_data'] = $extraData; |
|
| 46 | + public function store(int $userId, int $roomId, int $itemId, int $xPosition, int $yPosition, string $zPosition, int $rotation, string $extraData, string $wallPosition = ''): RoomItem |
|
| 47 | + { |
|
| 48 | + $this->attributes['user_id'] = $userId; |
|
| 49 | + $this->attributes['room_id'] = $roomId; |
|
| 50 | + $this->attributes['item_id'] = $itemId; |
|
| 51 | + $this->attributes['x'] = $xPosition; |
|
| 52 | + $this->attributes['y'] = $yPosition; |
|
| 53 | + $this->attributes['z'] = $zPosition; |
|
| 54 | + $this->attributes['rot'] = $rotation; |
|
| 55 | + $this->attributes['extra_data'] = $extraData; |
|
| 56 | 56 | |
| 57 | - if (!empty($wallPosition)) { |
|
| 58 | - $this->attributes['wall_pos'] = $wallPosition; |
|
| 59 | - } |
|
| 57 | + if (!empty($wallPosition)) { |
|
| 58 | + $this->attributes['wall_pos'] = $wallPosition; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $this->save(); |
|
| 61 | + $this->save(); |
|
| 62 | 62 | |
| 63 | - return $this; |
|
| 64 | - } |
|
| 63 | + return $this; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -1,62 +1,62 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | -use Sofa\Eloquence\Eloquence; |
|
| 6 | -use Sofa\Eloquence\Mappable; |
|
| 5 | + use Sofa\Eloquence\Eloquence; |
|
| 6 | + use Sofa\Eloquence\Mappable; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class ShopItem. |
| 10 | 10 | * |
| 11 | 11 | * @property mixed uniqueId |
| 12 | 12 | */ |
| 13 | -class ShopItem extends ChocolateyModel |
|
| 14 | -{ |
|
| 15 | - use Eloquence, Mappable; |
|
| 13 | + class ShopItem extends ChocolateyModel |
|
| 14 | + { |
|
| 15 | + use Eloquence, Mappable; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Disable Timestamps. |
| 19 | 19 | * |
| 20 | 20 | * @var bool |
| 21 | 21 | */ |
| 22 | - public $timestamps = false; |
|
| 22 | + public $timestamps = false; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * The table associated with the model. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $table = 'chocolatey_shop_items'; |
|
| 29 | + protected $table = 'chocolatey_shop_items'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Primary Key of the Table. |
| 33 | 33 | * |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - protected $primaryKey = 'id'; |
|
| 36 | + protected $primaryKey = 'id'; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * The Appender(s) of the Model. |
| 40 | 40 | * |
| 41 | 41 | * @var array |
| 42 | 42 | */ |
| 43 | - protected $appends = ['paymentMethods', 'uniqueId']; |
|
| 43 | + protected $appends = ['paymentMethods', 'uniqueId']; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * The attributes that will be mapped. |
| 47 | 47 | * |
| 48 | 48 | * @var array |
| 49 | 49 | */ |
| 50 | - protected $maps = ['paymentMethods' => 'payment_methods', 'uniqueId' => 'id']; |
|
| 50 | + protected $maps = ['paymentMethods' => 'payment_methods', 'uniqueId' => 'id']; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | + /** |
|
| 53 | 53 | * The attributes excluded from the model's JSON form. |
| 54 | 54 | * |
| 55 | 55 | * @var array |
| 56 | 56 | */ |
| 57 | - protected $hidden = ['payment_methods']; |
|
| 57 | + protected $hidden = ['payment_methods']; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | + /** |
|
| 60 | 60 | * Store an Shop Country. |
| 61 | 61 | * |
| 62 | 62 | * @param string $itemName |
@@ -67,54 +67,54 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return ShopItem |
| 69 | 69 | */ |
| 70 | - public function store(string $itemName, string $countryCode, int $creditAmount, int $iconId, array $paymentMethods): ShopItem |
|
| 71 | - { |
|
| 72 | - $this->attributes['name'] = $itemName; |
|
| 73 | - $this->attributes['countryCode'] = $countryCode; |
|
| 74 | - $this->attributes['creditAmount'] = $creditAmount; |
|
| 75 | - $this->attributes['iconId'] = $iconId; |
|
| 76 | - $this->attributes['payment_methods'] = implode(',', $paymentMethods); |
|
| 70 | + public function store(string $itemName, string $countryCode, int $creditAmount, int $iconId, array $paymentMethods): ShopItem |
|
| 71 | + { |
|
| 72 | + $this->attributes['name'] = $itemName; |
|
| 73 | + $this->attributes['countryCode'] = $countryCode; |
|
| 74 | + $this->attributes['creditAmount'] = $creditAmount; |
|
| 75 | + $this->attributes['iconId'] = $iconId; |
|
| 76 | + $this->attributes['payment_methods'] = implode(',', $paymentMethods); |
|
| 77 | 77 | |
| 78 | - $this->save(); |
|
| 78 | + $this->save(); |
|
| 79 | 79 | |
| 80 | - return $this; |
|
| 81 | - } |
|
| 80 | + return $this; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 83 | + /** |
|
| 84 | 84 | * Get Payment Methods. |
| 85 | 85 | * |
| 86 | 86 | * @return array |
| 87 | 87 | */ |
| 88 | - public function getPaymentMethodsAttribute(): array |
|
| 89 | - { |
|
| 90 | - $paymentMethods = []; |
|
| 88 | + public function getPaymentMethodsAttribute(): array |
|
| 89 | + { |
|
| 90 | + $paymentMethods = []; |
|
| 91 | 91 | |
| 92 | - if (!array_key_exists('payment_methods', $this->attributes)) { |
|
| 93 | - return $paymentMethods; |
|
| 94 | - } |
|
| 92 | + if (!array_key_exists('payment_methods', $this->attributes)) { |
|
| 93 | + return $paymentMethods; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - foreach (explode(',', $this->attributes['payment_methods']) as $shopCategory) { |
|
| 97 | - $paymentMethod = PaymentMethod::where('localizationKey', $shopCategory)->first(); |
|
| 98 | - $paymentMethod->setPurchaseParams([Country::where('countryCode', $this->attributes['countryCode'])->first()->uniqueId, $this->attributes['id']]); |
|
| 99 | - $paymentMethods[] = $paymentMethod; |
|
| 100 | - } |
|
| 96 | + foreach (explode(',', $this->attributes['payment_methods']) as $shopCategory) { |
|
| 97 | + $paymentMethod = PaymentMethod::where('localizationKey', $shopCategory)->first(); |
|
| 98 | + $paymentMethod->setPurchaseParams([Country::where('countryCode', $this->attributes['countryCode'])->first()->uniqueId, $this->attributes['id']]); |
|
| 99 | + $paymentMethods[] = $paymentMethod; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return $paymentMethods; |
|
| 103 | - } |
|
| 102 | + return $paymentMethods; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 105 | + /** |
|
| 106 | 106 | * Get Shop Item Categories. |
| 107 | 107 | * |
| 108 | 108 | * @return array |
| 109 | 109 | */ |
| 110 | - public function getCategoriesAttribute(): array |
|
| 111 | - { |
|
| 112 | - $shopCategories = []; |
|
| 110 | + public function getCategoriesAttribute(): array |
|
| 111 | + { |
|
| 112 | + $shopCategories = []; |
|
| 113 | 113 | |
| 114 | - foreach (explode(',', $this->attributes['categories']) as $shopCategory) { |
|
| 115 | - $shopCategories[] = ShopCategory::find($shopCategory)->category; |
|
| 116 | - } |
|
| 114 | + foreach (explode(',', $this->attributes['categories']) as $shopCategory) { |
|
| 115 | + $shopCategories[] = ShopCategory::find($shopCategory)->category; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return $shopCategories; |
|
| 119 | - } |
|
| 118 | + return $shopCategories; |
|
| 119 | + } |
|
| 120 | 120 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class ChocolateyMail. |
| 7 | 7 | */ |
| 8 | -class ChocolateyMail extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class ChocolateyMail extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'chocolatey_users_mail_requests'; |
|
| 22 | + protected $table = 'chocolatey_users_mail_requests'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Store a new Azure Id Account. |
| 33 | 33 | * |
| 34 | 34 | * @param string $userMail |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return ChocolateyMail |
| 38 | 38 | */ |
| 39 | - public function store(int $userId, string $userMail): ChocolateyMail |
|
| 40 | - { |
|
| 41 | - $this->attributes['user_id'] = $userId; |
|
| 42 | - $this->attributes['mail'] = $userMail; |
|
| 39 | + public function store(int $userId, string $userMail): ChocolateyMail |
|
| 40 | + { |
|
| 41 | + $this->attributes['user_id'] = $userId; |
|
| 42 | + $this->attributes['mail'] = $userMail; |
|
| 43 | 43 | |
| 44 | - $this->save(); |
|
| 44 | + $this->save(); |
|
| 45 | 45 | |
| 46 | - return $this; |
|
| 47 | - } |
|
| 46 | + return $this; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -1,41 +1,41 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class TrustedDevice. |
| 7 | 7 | */ |
| 8 | -class TrustedDevice extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class TrustedDevice extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'chocolatey_users_security_trusted'; |
|
| 22 | + protected $table = 'chocolatey_users_security_trusted'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * The attributes excluded from the model's JSON form. |
| 33 | 33 | * |
| 34 | 34 | * @var array |
| 35 | 35 | */ |
| 36 | - protected $hidden = ['id']; |
|
| 36 | + protected $hidden = ['id']; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Store a new TrustedDevice. |
| 40 | 40 | * |
| 41 | 41 | * @param int $userId |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return TrustedDevice |
| 45 | 45 | */ |
| 46 | - public function store(int $userId, string $ipAddress): TrustedDevice |
|
| 47 | - { |
|
| 48 | - $this->attributes['user_id'] = $userId; |
|
| 49 | - $this->attributes['ip_address'] = $ipAddress; |
|
| 46 | + public function store(int $userId, string $ipAddress): TrustedDevice |
|
| 47 | + { |
|
| 48 | + $this->attributes['user_id'] = $userId; |
|
| 49 | + $this->attributes['ip_address'] = $ipAddress; |
|
| 50 | 50 | |
| 51 | - $this->save(); |
|
| 51 | + $this->save(); |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | } |