@@ -1,30 +1,30 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Providers; |
|
| 3 | + namespace App\Providers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\User; |
|
| 6 | -use Illuminate\Support\Facades\Config; |
|
| 7 | -use Illuminate\Support\Facades\View; |
|
| 8 | -use Illuminate\Support\ServiceProvider; |
|
| 5 | + use App\Facades\User; |
|
| 6 | + use Illuminate\Support\Facades\Config; |
|
| 7 | + use Illuminate\Support\Facades\View; |
|
| 8 | + use Illuminate\Support\ServiceProvider; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Class ViewServiceProvider. |
| 12 | 12 | */ |
| 13 | -class ViewServiceProvider extends ServiceProvider |
|
| 14 | -{ |
|
| 15 | - /** |
|
| 13 | + class ViewServiceProvider extends ServiceProvider |
|
| 14 | + { |
|
| 15 | + /** |
|
| 16 | 16 | * Configures all Global Blade Variables. |
| 17 | 17 | * |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | - public function register() |
|
| 21 | - { |
|
| 22 | - View::share('chocolatey', json_decode(json_encode(Config::get('chocolatey')))); |
|
| 20 | + public function register() |
|
| 21 | + { |
|
| 22 | + View::share('chocolatey', json_decode(json_encode(Config::get('chocolatey')))); |
|
| 23 | 23 | |
| 24 | - View::share('user', User::getUser() ?? 'null'); |
|
| 24 | + View::share('user', User::getUser() ?? 'null'); |
|
| 25 | 25 | |
| 26 | - View::share('mail', json_decode(json_encode(Config::get('mail')))); |
|
| 26 | + View::share('mail', json_decode(json_encode(Config::get('mail')))); |
|
| 27 | 27 | |
| 28 | - View::share('maintenance', json_decode(json_encode(Config::get('maintenance')))); |
|
| 29 | - } |
|
| 28 | + View::share('maintenance', json_decode(json_encode(Config::get('maintenance')))); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -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,25 +46,25 @@ 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 | * Retrieve Non Banned Users (If all Users are Banned, return the Banned user Also). |
| 69 | 69 | * |
| 70 | 70 | * @param Request $request |
@@ -72,20 +72,20 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return UserModel |
| 74 | 74 | */ |
| 75 | - private function checkForBanAlternative(Request $request, ChocolateyId $chocolateyId) |
|
| 76 | - { |
|
| 77 | - $temporaryUsers = UserModel::where('mail', $request->json()->get('email'))->get(); |
|
| 75 | + private function checkForBanAlternative(Request $request, ChocolateyId $chocolateyId) |
|
| 76 | + { |
|
| 77 | + $temporaryUsers = UserModel::where('mail', $request->json()->get('email'))->get(); |
|
| 78 | 78 | |
| 79 | - foreach ($temporaryUsers as $forUser) { |
|
| 80 | - if (!$forUser->isBanned) { |
|
| 81 | - return $forUser; |
|
| 82 | - } |
|
| 83 | - } |
|
| 79 | + foreach ($temporaryUsers as $forUser) { |
|
| 80 | + if (!$forUser->isBanned) { |
|
| 81 | + return $forUser; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return $temporaryUsers->get(0); |
|
| 86 | - } |
|
| 85 | + return $temporaryUsers->get(0); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | + /** |
|
| 89 | 89 | * Get Users. |
| 90 | 90 | * |
| 91 | 91 | * @param Request $request |
@@ -93,65 +93,65 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return UserModel |
| 95 | 95 | */ |
| 96 | - private function retrieveUser(Request $request, ChocolateyId $chocolateyId) |
|
| 97 | - { |
|
| 98 | - if ($chocolateyId->last_logged_id != 0) { |
|
| 99 | - $temporaryUser = UserModel::find($chocolateyId->last_logged_id); |
|
| 96 | + private function retrieveUser(Request $request, ChocolateyId $chocolateyId) |
|
| 97 | + { |
|
| 98 | + if ($chocolateyId->last_logged_id != 0) { |
|
| 99 | + $temporaryUser = UserModel::find($chocolateyId->last_logged_id); |
|
| 100 | 100 | |
| 101 | - if ($temporaryUser->isBanned) { |
|
| 102 | - return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 103 | - } |
|
| 101 | + if ($temporaryUser->isBanned) { |
|
| 102 | + return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $temporaryUser; |
|
| 106 | - } |
|
| 105 | + return $temporaryUser; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $temporaryUser = UserModel::where('mail', $request->json()->get('email'))->first(); |
|
| 108 | + $temporaryUser = UserModel::where('mail', $request->json()->get('email'))->first(); |
|
| 109 | 109 | |
| 110 | - if ($temporaryUser->isBanned) { |
|
| 111 | - return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 112 | - } |
|
| 110 | + if ($temporaryUser->isBanned) { |
|
| 111 | + return $this->checkForBanAlternative($request, $chocolateyId); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $temporaryUser; |
|
| 115 | - } |
|
| 114 | + return $temporaryUser; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 117 | + /** |
|
| 118 | 118 | * Set Session From Login Credentials. |
| 119 | 119 | * |
| 120 | 120 | * @param Request $request |
| 121 | 121 | * |
| 122 | 122 | * @return UserModel |
| 123 | 123 | */ |
| 124 | - public function loginUser(Request $request) |
|
| 125 | - { |
|
| 126 | - $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 124 | + public function loginUser(Request $request) |
|
| 125 | + { |
|
| 126 | + $chocolateyId = ChocolateyId::find($request->json()->get('email')); |
|
| 127 | 127 | |
| 128 | - if ($chocolateyId == null) { |
|
| 129 | - return; |
|
| 130 | - } |
|
| 128 | + if ($chocolateyId == null) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - $user = $this->retrieveUser($request, $chocolateyId); |
|
| 132 | + $user = $this->retrieveUser($request, $chocolateyId); |
|
| 133 | 133 | |
| 134 | - $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 134 | + $chocolateyId->last_logged_id = $user->uniqueId; |
|
| 135 | 135 | |
| 136 | - return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 137 | - ? $this->setSession($user) : null; |
|
| 138 | - } |
|
| 136 | + return $chocolateyId->password == hash(Config::get('chocolatey.security.hash'), $request->json()->get('password')) |
|
| 137 | + ? $this->setSession($user) : null; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 140 | + /** |
|
| 141 | 141 | * Return if USer Session Exists. |
| 142 | 142 | * |
| 143 | 143 | * @return bool |
| 144 | 144 | */ |
| 145 | - public function hasSession() |
|
| 146 | - { |
|
| 147 | - return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 148 | - } |
|
| 145 | + public function hasSession() |
|
| 146 | + { |
|
| 147 | + return (bool) Session::get(Config::get('chocolatey.security.session')); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 150 | + /** |
|
| 151 | 151 | * Erase User Session. |
| 152 | 152 | */ |
| 153 | - public function eraseSession() |
|
| 154 | - { |
|
| 155 | - Session::erase(Config::get('chocolatey.security.session')); |
|
| 156 | - } |
|
| 153 | + public function eraseSession() |
|
| 154 | + { |
|
| 155 | + Session::erase(Config::get('chocolatey.security.session')); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -1,64 +1,64 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class ShopCategory. |
| 7 | 7 | */ |
| 8 | -class ShopCategory extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class ShopCategory 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_shop_items_categories'; |
|
| 22 | + protected $table = 'chocolatey_shop_items_categories'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'category_name'; |
|
| 29 | + protected $primaryKey = 'category_name'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * The Appender(s) of the Model. |
| 33 | 33 | * |
| 34 | 34 | * @var array |
| 35 | 35 | */ |
| 36 | - protected $appends = ['category']; |
|
| 36 | + protected $appends = ['category']; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Store an Shop Country. |
| 40 | 40 | * |
| 41 | 41 | * @param string $categoryName |
| 42 | 42 | * |
| 43 | 43 | * @return ShopCategory |
| 44 | 44 | */ |
| 45 | - public function store(string $categoryName): ShopCategory |
|
| 46 | - { |
|
| 47 | - $this->attributes['category_name'] = $categoryName; |
|
| 48 | - $this->timestamps = false; |
|
| 45 | + public function store(string $categoryName): ShopCategory |
|
| 46 | + { |
|
| 47 | + $this->attributes['category_name'] = $categoryName; |
|
| 48 | + $this->timestamps = false; |
|
| 49 | 49 | |
| 50 | - $this->save(); |
|
| 50 | + $this->save(); |
|
| 51 | 51 | |
| 52 | - return $this; |
|
| 53 | - } |
|
| 52 | + return $this; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | + /** |
|
| 56 | 56 | * Get Shop Category Name. |
| 57 | 57 | * |
| 58 | 58 | * @return string |
| 59 | 59 | */ |
| 60 | - public function getCategoryAttribute(): string |
|
| 61 | - { |
|
| 62 | - return $this->attributes['category_name']; |
|
| 63 | - } |
|
| 60 | + public function getCategoryAttribute(): string |
|
| 61 | + { |
|
| 62 | + return $this->attributes['category_name']; |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -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,30 +41,30 @@ 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; |
|
| 54 | - $this->timestamps = false; |
|
| 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 | + $this->timestamps = false; |
|
| 55 | 55 | |
| 56 | - $this->save(); |
|
| 56 | + $this->save(); |
|
| 57 | 57 | |
| 58 | - return $this; |
|
| 59 | - } |
|
| 58 | + return $this; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | + /** |
|
| 62 | 62 | * Get Ban Expire Attribute. |
| 63 | 63 | * |
| 64 | 64 | * @return string |
| 65 | 65 | */ |
| 66 | - public function getBanExpireAttribute(): string |
|
| 67 | - { |
|
| 68 | - return date('M/d/Y h:m A', $this->attributes['ban_expire']); |
|
| 69 | - } |
|
| 66 | + public function getBanExpireAttribute(): string |
|
| 67 | + { |
|
| 68 | + return date('M/d/Y h:m A', $this->attributes['ban_expire']); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -1,117 +1,117 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | -use Illuminate\Support\Facades\DB; |
|
| 6 | -use Sofa\Eloquence\Eloquence; |
|
| 7 | -use Sofa\Eloquence\Mappable; |
|
| 5 | + use Illuminate\Support\Facades\DB; |
|
| 6 | + use Sofa\Eloquence\Eloquence; |
|
| 7 | + use Sofa\Eloquence\Mappable; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Class ShopHistory. |
| 11 | 11 | * |
| 12 | 12 | * @property int transactionId |
| 13 | 13 | */ |
| 14 | -class ShopHistory extends ChocolateyModel |
|
| 15 | -{ |
|
| 16 | - use Eloquence, Mappable; |
|
| 14 | + class ShopHistory extends ChocolateyModel |
|
| 15 | + { |
|
| 16 | + use Eloquence, Mappable; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 18 | + /** |
|
| 19 | 19 | * The table associated with the model. |
| 20 | 20 | * |
| 21 | 21 | * @var string |
| 22 | 22 | */ |
| 23 | - protected $table = 'chocolatey_shop_history'; |
|
| 23 | + protected $table = 'chocolatey_shop_history'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 25 | + /** |
|
| 26 | 26 | * Primary Key of the Table. |
| 27 | 27 | * |
| 28 | 28 | * @var string |
| 29 | 29 | */ |
| 30 | - protected $primaryKey = 'id'; |
|
| 30 | + protected $primaryKey = 'id'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * The attributes that will be mapped. |
| 34 | 34 | * |
| 35 | 35 | * @var array |
| 36 | 36 | */ |
| 37 | - protected $maps = ['transactionSystemName' => 'payment_method', 'transactionId' => 'id']; |
|
| 37 | + protected $maps = ['transactionSystemName' => 'payment_method', 'transactionId' => 'id']; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | + /** |
|
| 40 | 40 | * The Appender(s) of the Model. |
| 41 | 41 | * |
| 42 | 42 | * @var array |
| 43 | 43 | */ |
| 44 | - protected $appends = ['creationTime', 'transactionSystemName', 'credits', 'price', 'transactionId', 'product']; |
|
| 44 | + protected $appends = ['creationTime', 'transactionSystemName', 'credits', 'price', 'transactionId', 'product']; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | + /** |
|
| 47 | 47 | * The attributes excluded from the model's JSON form. |
| 48 | 48 | * |
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | - protected $hidden = ['created_at', 'updated_at', 'approved_by', 'user_id', 'item_id']; |
|
| 51 | + protected $hidden = ['created_at', 'updated_at', 'approved_by', 'user_id', 'item_id']; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | + /** |
|
| 54 | 54 | * Get Creation Time Attribute. |
| 55 | 55 | * |
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | - public function getCreationTimeAttribute(): string |
|
| 59 | - { |
|
| 60 | - return date('Y-m-d', strtotime($this->attributes['created_at'])).'T'. |
|
| 61 | - date('H:i:s.ZZZZ+ZZZZ', strtotime($this->attributes['created_at'])); |
|
| 62 | - } |
|
| 58 | + public function getCreationTimeAttribute(): string |
|
| 59 | + { |
|
| 60 | + return date('Y-m-d', strtotime($this->attributes['created_at'])).'T'. |
|
| 61 | + date('H:i:s.ZZZZ+ZZZZ', strtotime($this->attributes['created_at'])); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 64 | + /** |
|
| 65 | 65 | * Get Payment Method Name. |
| 66 | 66 | * |
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | - public function getTransactionSystemNameAttribute(): string |
|
| 70 | - { |
|
| 71 | - return PaymentMethod::find($this->attributes['payment_method'])->name; |
|
| 72 | - } |
|
| 69 | + public function getTransactionSystemNameAttribute(): string |
|
| 70 | + { |
|
| 71 | + return PaymentMethod::find($this->attributes['payment_method'])->name; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 74 | + /** |
|
| 75 | 75 | * Get Transaction Id. |
| 76 | 76 | * |
| 77 | 77 | * @return int |
| 78 | 78 | */ |
| 79 | - public function getTransactionIdAttribute(): int |
|
| 80 | - { |
|
| 81 | - return $this->attributes['id']; |
|
| 82 | - } |
|
| 79 | + public function getTransactionIdAttribute(): int |
|
| 80 | + { |
|
| 81 | + return $this->attributes['id']; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 84 | + /** |
|
| 85 | 85 | * Get Amount of Given Credits. |
| 86 | 86 | * |
| 87 | 87 | * @return int |
| 88 | 88 | */ |
| 89 | - public function getCreditsAttribute(): int |
|
| 90 | - { |
|
| 91 | - return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first()->creditAmount; |
|
| 92 | - } |
|
| 89 | + public function getCreditsAttribute(): int |
|
| 90 | + { |
|
| 91 | + return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first()->creditAmount; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 94 | + /** |
|
| 95 | 95 | * Get Product Attribute. |
| 96 | 96 | * |
| 97 | 97 | * @return mixed|object|array |
| 98 | 98 | */ |
| 99 | - public function getProductAttribute() |
|
| 100 | - { |
|
| 101 | - return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first(['name', 'description']); |
|
| 102 | - } |
|
| 99 | + public function getProductAttribute() |
|
| 100 | + { |
|
| 101 | + return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first(['name', 'description']); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 104 | + /** |
|
| 105 | 105 | * Get Price Attribute. |
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - public function getPriceAttribute(): string |
|
| 110 | - { |
|
| 111 | - return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first()->price; |
|
| 112 | - } |
|
| 109 | + public function getPriceAttribute(): string |
|
| 110 | + { |
|
| 111 | + return DB::table('chocolatey_shop_items')->where('id', $this->attributes['item_id'])->first()->price; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 114 | + /** |
|
| 115 | 115 | * Store a new Purchase. |
| 116 | 116 | * |
| 117 | 117 | * @param int $paymentMethod |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return ShopHistory |
| 122 | 122 | */ |
| 123 | - public function store(int $paymentMethod, int $userId, int $itemId): ShopHistory |
|
| 124 | - { |
|
| 125 | - $this->attributes['payment_method'] = $paymentMethod; |
|
| 126 | - $this->attributes['user_id'] = $userId; |
|
| 127 | - $this->attributes['item_id'] = $itemId; |
|
| 123 | + public function store(int $paymentMethod, int $userId, int $itemId): ShopHistory |
|
| 124 | + { |
|
| 125 | + $this->attributes['payment_method'] = $paymentMethod; |
|
| 126 | + $this->attributes['user_id'] = $userId; |
|
| 127 | + $this->attributes['item_id'] = $itemId; |
|
| 128 | 128 | |
| 129 | - $this->save(); |
|
| 129 | + $this->save(); |
|
| 130 | 130 | |
| 131 | - return $this; |
|
| 132 | - } |
|
| 131 | + return $this; |
|
| 132 | + } |
|
| 133 | 133 | } |
@@ -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,14 +43,14 @@ 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; |
|
| 50 | - $this->timestamps = false; |
|
| 46 | + public function store(int $userId, string $ipAddress): TrustedDevice |
|
| 47 | + { |
|
| 48 | + $this->attributes['user_id'] = $userId; |
|
| 49 | + $this->attributes['ip_address'] = $ipAddress; |
|
| 50 | + $this->timestamps = false; |
|
| 51 | 51 | |
| 52 | - $this->save(); |
|
| 52 | + $this->save(); |
|
| 53 | 53 | |
| 54 | - return $this; |
|
| 55 | - } |
|
| 54 | + return $this; |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -1,43 +1,43 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | -use Illuminate\Database\Eloquent\Builder; |
|
| 5 | + use Illuminate\Database\Eloquent\Builder; |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Class PhotoReport. |
| 9 | 9 | */ |
| 10 | -class PhotoReport extends ChocolateyModel |
|
| 11 | -{ |
|
| 12 | - /** |
|
| 10 | + class PhotoReport extends ChocolateyModel |
|
| 11 | + { |
|
| 12 | + /** |
|
| 13 | 13 | * Disable Timestamps. |
| 14 | 14 | * |
| 15 | 15 | * @var bool |
| 16 | 16 | */ |
| 17 | - public $timestamps = false; |
|
| 17 | + public $timestamps = false; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | + /** |
|
| 20 | 20 | * The table associated with the model. |
| 21 | 21 | * |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - protected $table = 'chocolatey_users_photos_reported'; |
|
| 24 | + protected $table = 'chocolatey_users_photos_reported'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | + /** |
|
| 27 | 27 | * Primary Key of the Table. |
| 28 | 28 | * |
| 29 | 29 | * @var string |
| 30 | 30 | */ |
| 31 | - protected $primaryKey = 'id'; |
|
| 31 | + protected $primaryKey = 'id'; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | + /** |
|
| 34 | 34 | * The Appender(s) of the Model. |
| 35 | 35 | * |
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - protected $appends = ['reason_category']; |
|
| 38 | + protected $appends = ['reason_category']; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | + /** |
|
| 41 | 41 | * Store a new Photo Report. |
| 42 | 42 | * |
| 43 | 43 | * @param int $photoId |
@@ -46,26 +46,26 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return PhotoReport |
| 48 | 48 | */ |
| 49 | - public function store(int $photoId, int $reasonId, int $reportedBy): PhotoReport |
|
| 50 | - { |
|
| 51 | - $this->attributes['photo_id'] = $photoId; |
|
| 52 | - $this->attributes['reason_id'] = $reasonId; |
|
| 53 | - $this->attributes['reported_by'] = $reportedBy; |
|
| 54 | - $this->attributes['approved'] = 0; |
|
| 55 | - $this->timestamps = false; |
|
| 49 | + public function store(int $photoId, int $reasonId, int $reportedBy): PhotoReport |
|
| 50 | + { |
|
| 51 | + $this->attributes['photo_id'] = $photoId; |
|
| 52 | + $this->attributes['reason_id'] = $reasonId; |
|
| 53 | + $this->attributes['reported_by'] = $reportedBy; |
|
| 54 | + $this->attributes['approved'] = 0; |
|
| 55 | + $this->timestamps = false; |
|
| 56 | 56 | |
| 57 | - $this->save(); |
|
| 57 | + $this->save(); |
|
| 58 | 58 | |
| 59 | - return $this; |
|
| 60 | - } |
|
| 59 | + return $this; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | + /** |
|
| 63 | 63 | * Get the Report Category Content. |
| 64 | 64 | * |
| 65 | 65 | * @return Builder |
| 66 | 66 | */ |
| 67 | - public function getReasonCategoryAttribute() |
|
| 68 | - { |
|
| 69 | - return PhotoReportCategory::query()->where('report_category', $this->attributes['reason_id'])->first(); |
|
| 70 | - } |
|
| 67 | + public function getReasonCategoryAttribute() |
|
| 68 | + { |
|
| 69 | + return PhotoReportCategory::query()->where('report_category', $this->attributes['reason_id'])->first(); |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -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 PhotoLike. |
| 7 | 7 | */ |
| 8 | -class PhotoLike extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class PhotoLike 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_photos_likes'; |
|
| 22 | + protected $table = 'chocolatey_users_photos_likes'; |
|
| 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 Photo Data. |
| 33 | 33 | * |
| 34 | 34 | * @param int $photoId |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return PhotoLike |
| 38 | 38 | */ |
| 39 | - public function store(int $photoId, string $userName): PhotoLike |
|
| 40 | - { |
|
| 41 | - $this->attributes['photo_id'] = $photoId; |
|
| 42 | - $this->attributes['username'] = $userName; |
|
| 43 | - $this->timestamps = false; |
|
| 39 | + public function store(int $photoId, string $userName): PhotoLike |
|
| 40 | + { |
|
| 41 | + $this->attributes['photo_id'] = $photoId; |
|
| 42 | + $this->attributes['username'] = $userName; |
|
| 43 | + $this->timestamps = false; |
|
| 44 | 44 | |
| 45 | - $this->save(); |
|
| 45 | + $this->save(); |
|
| 46 | 46 | |
| 47 | - return $this; |
|
| 48 | - } |
|
| 47 | + return $this; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -1,47 +1,47 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class PaymentCategory. |
| 7 | 7 | */ |
| 8 | -class PaymentCategory extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class PaymentCategory 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_shop_payment_categories'; |
|
| 22 | + protected $table = 'chocolatey_shop_payment_categories'; |
|
| 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 Shop Country. |
| 33 | 33 | * |
| 34 | 34 | * @param string $paymentName |
| 35 | 35 | * |
| 36 | 36 | * @return PaymentCategory |
| 37 | 37 | */ |
| 38 | - public function store(string $paymentName): PaymentCategory |
|
| 39 | - { |
|
| 40 | - $this->attributes['payment_type'] = $paymentName; |
|
| 41 | - $this->timestamps = false; |
|
| 38 | + public function store(string $paymentName): PaymentCategory |
|
| 39 | + { |
|
| 40 | + $this->attributes['payment_type'] = $paymentName; |
|
| 41 | + $this->timestamps = false; |
|
| 42 | 42 | |
| 43 | - $this->save(); |
|
| 43 | + $this->save(); |
|
| 44 | 44 | |
| 45 | - return $this; |
|
| 46 | - } |
|
| 45 | + return $this; |
|
| 46 | + } |
|
| 47 | 47 | } |