commit
699a4bda95
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
![](https://img.shields.io/endpoint?label=v0.8%20Installations&url=https%3A%2F%2Fmarket.controlpanel.gg%2Fcallhome.php%3Fgetinstalls)
|
![](https://img.shields.io/endpoint?label=v0.8%20Installations&url=https%3A%2F%2Fmarket.controlpanel.gg%2Fcallhome.php%3Fgetinstalls)
|
||||||
![](https://img.shields.io/badge/Overall%20Installations-2500%2B-green)
|
![](https://img.shields.io/badge/Overall%20Installations-3500%2B-green)
|
||||||
![](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/forks/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) [![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/license/ControlPanel-gg/dashboard) ![](https://img.shields.io/discord/787829714483019826)
|
![](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/forks/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) [![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/license/ControlPanel-gg/dashboard) ![](https://img.shields.io/discord/787829714483019826)
|
||||||
## About
|
## About
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ namespace App\Classes;
|
||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Nest;
|
use App\Models\Nest;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
|
use App\Models\Server;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Http\Client\PendingRequest;
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
use Illuminate\Http\Client\Response;
|
use Illuminate\Http\Client\Response;
|
||||||
|
@ -22,129 +22,152 @@ class Pterodactyl
|
||||||
public static function client()
|
public static function client()
|
||||||
{
|
{
|
||||||
return Http::withHeaders([
|
return Http::withHeaders([
|
||||||
'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:TOKEN"),
|
'Authorization' => 'Bearer '.config('SETTINGS::SYSTEM:PTERODACTYL:TOKEN'),
|
||||||
'Content-type' => 'application/json',
|
'Content-type' => 'application/json',
|
||||||
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
||||||
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
])->baseUrl(config('SETTINGS::SYSTEM:PTERODACTYL:URL').'/api');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function clientAdmin()
|
public static function clientAdmin()
|
||||||
{
|
{
|
||||||
return Http::withHeaders([
|
return Http::withHeaders([
|
||||||
'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN"),
|
'Authorization' => 'Bearer '.config('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN'),
|
||||||
'Content-type' => 'application/json',
|
'Content-type' => 'application/json',
|
||||||
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
||||||
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
])->baseUrl(config('SETTINGS::SYSTEM:PTERODACTYL:URL').'/api');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Exception
|
* @return Exception
|
||||||
*/
|
*/
|
||||||
private static function getException(string $message = "", int $status = 0): Exception
|
private static function getException(string $message = '', int $status = 0): Exception
|
||||||
{
|
{
|
||||||
if ($status == 404) {
|
if ($status == 404) {
|
||||||
return new Exception("Ressource does not exist on pterodactyl - " . $message, 404);
|
return new Exception('Ressource does not exist on pterodactyl - '.$message, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status == 403) {
|
if ($status == 403) {
|
||||||
return new Exception("No permission on pterodactyl, check pterodactyl token and permissions - " . $message, 403);
|
return new Exception('No permission on pterodactyl, check pterodactyl token and permissions - '.$message, 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status == 401) {
|
if ($status == 401) {
|
||||||
return new Exception("No pterodactyl token set - " . $message, 401);
|
return new Exception('No pterodactyl token set - '.$message, 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status == 500) {
|
if ($status == 500) {
|
||||||
return new Exception("Pterodactyl server error - " . $message, 500);
|
return new Exception('Pterodactyl server error - '.$message, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Exception('Request Failed, is pterodactyl set-up correctly? - ' . $message);
|
return new Exception('Request Failed, is pterodactyl set-up correctly? - '.$message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Nest $nest
|
* @param Nest $nest
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getEggs(Nest $nest)
|
public static function getEggs(Nest $nest)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
|
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=".config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get eggs from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get eggs from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return $response->json()['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getNodes()
|
public static function getNodes()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = self::client()->get('/application/nodes?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
|
$response = self::client()->get('/application/nodes?per_page='.config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get nodes from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get nodes from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return $response->json()['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @description Returns the infos of a single node
|
* @description Returns the infos of a single node
|
||||||
*/
|
*/
|
||||||
public static function getNode($id) {
|
public static function getNode($id)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$response = self::client()->get('/application/nodes/' . $id);
|
$response = self::client()->get('/application/nodes/'.$id);
|
||||||
} catch(Exception $e) {
|
|
||||||
throw self::getException($e->getMessage());
|
|
||||||
}
|
|
||||||
if($response->failed()) throw self::getException("Failed to get node id " . $id . " - " . $response->status());
|
|
||||||
return $response->json()['attributes'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getServers() {
|
|
||||||
try {
|
|
||||||
$response = self::client()->get('/application/servers?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if($response->failed()) throw self::getException("Failed to get list of servers - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get node id '.$id.' - '.$response->status());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->json()['attributes'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getServers()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = self::client()->get('/application/servers?per_page='.config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT'));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw self::getException($e->getMessage());
|
||||||
|
}
|
||||||
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get list of servers - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return $response->json()['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null
|
* @return null
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getNests()
|
public static function getNests()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = self::client()->get('/application/nests?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
|
$response = self::client()->get('/application/nests?per_page='.config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get nests from pterodactyl", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get nests from pterodactyl', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return $response->json()['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getLocations()
|
public static function getLocations()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = self::client()->get('/application/locations?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
|
$response = self::client()->get('/application/locations?per_page='.config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get locations from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get locations from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return $response->json()['data'];
|
||||||
}
|
}
|
||||||
|
@ -152,6 +175,7 @@ class Pterodactyl
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getFreeAllocationId(Node $node)
|
public static function getFreeAllocationId(Node $node)
|
||||||
|
@ -162,6 +186,7 @@ class Pterodactyl
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @return array|mixed|null
|
* @return array|mixed|null
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getFreeAllocations(Node $node)
|
public static function getFreeAllocations(Node $node)
|
||||||
|
@ -170,9 +195,11 @@ class Pterodactyl
|
||||||
$freeAllocations = [];
|
$freeAllocations = [];
|
||||||
|
|
||||||
if (isset($response['data'])) {
|
if (isset($response['data'])) {
|
||||||
if (!empty($response['data'])) {
|
if (! empty($response['data'])) {
|
||||||
foreach ($response['data'] as $allocation) {
|
foreach ($response['data'] as $allocation) {
|
||||||
if (!$allocation['attributes']['assigned']) array_push($freeAllocations, $allocation);
|
if (! $allocation['attributes']['assigned']) {
|
||||||
|
array_push($freeAllocations, $allocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,6 +210,7 @@ class Pterodactyl
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @return array|mixed
|
* @return array|mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getAllocations(Node $node)
|
public static function getAllocations(Node $node)
|
||||||
|
@ -193,18 +221,20 @@ class Pterodactyl
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get allocations from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get allocations from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json();
|
return $response->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $route
|
* @param string $route
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function url(string $route): string
|
public static function url(string $route): string
|
||||||
{
|
{
|
||||||
return config("SETTINGS::SYSTEM:PTERODACTYL:URL") . $route;
|
return config('SETTINGS::SYSTEM:PTERODACTYL:URL').$route;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,29 +245,29 @@ class Pterodactyl
|
||||||
*/
|
*/
|
||||||
public static function createServer(Server $server, Egg $egg, int $allocationId)
|
public static function createServer(Server $server, Egg $egg, int $allocationId)
|
||||||
{
|
{
|
||||||
return self::client()->post("/application/servers", [
|
return self::client()->post('/application/servers', [
|
||||||
"name" => $server->name,
|
'name' => $server->name,
|
||||||
"external_id" => $server->id,
|
'external_id' => $server->id,
|
||||||
"user" => $server->user->pterodactyl_id,
|
'user' => $server->user->pterodactyl_id,
|
||||||
"egg" => $egg->id,
|
'egg' => $egg->id,
|
||||||
"docker_image" => $egg->docker_image,
|
'docker_image' => $egg->docker_image,
|
||||||
"startup" => $egg->startup,
|
'startup' => $egg->startup,
|
||||||
"environment" => $egg->getEnvironmentVariables(),
|
'environment' => $egg->getEnvironmentVariables(),
|
||||||
"limits" => [
|
'limits' => [
|
||||||
"memory" => $server->product->memory,
|
'memory' => $server->product->memory,
|
||||||
"swap" => $server->product->swap,
|
'swap' => $server->product->swap,
|
||||||
"disk" => $server->product->disk,
|
'disk' => $server->product->disk,
|
||||||
"io" => $server->product->io,
|
'io' => $server->product->io,
|
||||||
"cpu" => $server->product->cpu
|
'cpu' => $server->product->cpu,
|
||||||
],
|
],
|
||||||
"feature_limits" => [
|
'feature_limits' => [
|
||||||
"databases" => $server->product->databases,
|
'databases' => $server->product->databases,
|
||||||
"backups" => $server->product->backups,
|
'backups' => $server->product->backups,
|
||||||
"allocations" => $server->product->allocations,
|
'allocations' => $server->product->allocations,
|
||||||
|
],
|
||||||
|
'allocation' => [
|
||||||
|
'default' => $allocationId,
|
||||||
],
|
],
|
||||||
"allocation" => [
|
|
||||||
"default" => $allocationId
|
|
||||||
]
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +278,9 @@ class Pterodactyl
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to suspend server from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to suspend server from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -260,13 +292,16 @@ class Pterodactyl
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to unsuspend server from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to unsuspend server from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by pterodactyl id
|
* Get user by pterodactyl id
|
||||||
|
*
|
||||||
* @param int $pterodactylId
|
* @param int $pterodactylId
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -277,13 +312,16 @@ class Pterodactyl
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($response->failed()) throw self::getException("Failed to get user from pterodactyl - ", $response->status());
|
if ($response->failed()) {
|
||||||
|
throw self::getException('Failed to get user from pterodactyl - ', $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
return $response->json()['attributes'];
|
return $response->json()['attributes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get serverAttributes by pterodactyl id
|
* Get serverAttributes by pterodactyl id
|
||||||
|
*
|
||||||
* @param int $pterodactylId
|
* @param int $pterodactylId
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -297,20 +335,22 @@ class Pterodactyl
|
||||||
|
|
||||||
//print response body
|
//print response body
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
if ($deleteOn404) { //Delete the server if it does not exist (server deleted on pterodactyl)
|
||||||
if ($response->failed()){
|
|
||||||
if($deleteOn404){ //Delete the server if it does not exist (server deleted on pterodactyl)
|
|
||||||
Server::where('pterodactyl_id', $pterodactylId)->first()->delete();
|
Server::where('pterodactyl_id', $pterodactylId)->first()->delete();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
throw self::getException('Failed to get server attributes from pterodactyl - ', $response->status());
|
||||||
}
|
}
|
||||||
else throw self::getException("Failed to get server attributes from pterodactyl - ", $response->status());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->json()['attributes'];
|
return $response->json()['attributes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Server Resources
|
* Update Server Resources
|
||||||
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param Product $product
|
* @param Product $product
|
||||||
* @return Response
|
* @return Response
|
||||||
|
@ -318,22 +358,24 @@ class Pterodactyl
|
||||||
public static function updateServer(Server $server, Product $product)
|
public static function updateServer(Server $server, Product $product)
|
||||||
{
|
{
|
||||||
return self::client()->patch("/application/servers/{$server->pterodactyl_id}/build", [
|
return self::client()->patch("/application/servers/{$server->pterodactyl_id}/build", [
|
||||||
"allocation" => $server->allocation,
|
'allocation' => $server->allocation,
|
||||||
"memory" => $product->memory,
|
'memory' => $product->memory,
|
||||||
"swap" => $product->swap,
|
'swap' => $product->swap,
|
||||||
"disk" => $product->disk,
|
'disk' => $product->disk,
|
||||||
"io" => $product->io,
|
'io' => $product->io,
|
||||||
"cpu" => $product->cpu,
|
'cpu' => $product->cpu,
|
||||||
"threads" => null,
|
'threads' => null,
|
||||||
"feature_limits" => [
|
'feature_limits' => [
|
||||||
"databases" => $product->databases,
|
'databases' => $product->databases,
|
||||||
"backups" => $product->backups,
|
'backups' => $product->backups,
|
||||||
"allocations" => $product->allocations,
|
'allocations' => $product->allocations,
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Power Action Specific Server
|
* Power Action Specific Server
|
||||||
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param string $action
|
* @param string $action
|
||||||
* @return Response
|
* @return Response
|
||||||
|
@ -341,7 +383,7 @@ class Pterodactyl
|
||||||
public static function powerAction(Server $server, $action)
|
public static function powerAction(Server $server, $action)
|
||||||
{
|
{
|
||||||
return self::clientAdmin()->post("/client/servers/{$server->identifier}/power", [
|
return self::clientAdmin()->post("/client/servers/{$server->identifier}/power", [
|
||||||
"signal" => $action
|
'signal' => $action,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,16 +392,16 @@ class Pterodactyl
|
||||||
*/
|
*/
|
||||||
public static function getClientUser()
|
public static function getClientUser()
|
||||||
{
|
{
|
||||||
return self::clientAdmin()->get("/client/account");
|
return self::clientAdmin()->get('/client/account');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if node has enough free resources to allocate the given resources
|
* Check if node has enough free resources to allocate the given resources
|
||||||
|
*
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @param int $requireMemory
|
* @param int $requireMemory
|
||||||
* @param int $requireDisk
|
* @param int $requireDisk
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function checkNodeResources(Node $node, int $requireMemory, int $requireDisk)
|
public static function checkNodeResources(Node $node, int $requireMemory, int $requireDisk)
|
||||||
{
|
{
|
||||||
|
@ -369,14 +411,15 @@ class Pterodactyl
|
||||||
throw self::getException($e->getMessage());
|
throw self::getException($e->getMessage());
|
||||||
}
|
}
|
||||||
$node = $response['attributes'];
|
$node = $response['attributes'];
|
||||||
$freeMemory = ($node['memory']*($node['memory_overallocate']+100)/100) - $node['allocated_resources']['memory'];
|
$freeMemory = ($node['memory'] * ($node['memory_overallocate'] + 100) / 100) - $node['allocated_resources']['memory'];
|
||||||
$freeDisk = ($node['disk']*($node['disk_overallocate']+100)/100) - $node['allocated_resources']['disk'];
|
$freeDisk = ($node['disk'] * ($node['disk_overallocate'] + 100) / 100) - $node['allocated_resources']['disk'];
|
||||||
if ($freeMemory < $requireMemory) {
|
if ($freeMemory < $requireMemory) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($freeDisk < $requireDisk) {
|
if ($freeDisk < $requireDisk) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,8 @@ class Invoices
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateSettings(Request $request)
|
public function updateSettings(Request $request)
|
||||||
{
|
{
|
||||||
|
@ -22,29 +21,27 @@ class Invoices
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||||
"SETTINGS::INVOICE:COMPANY_NAME" => "company-name",
|
'SETTINGS::INVOICE:COMPANY_NAME' => 'company-name',
|
||||||
"SETTINGS::INVOICE:COMPANY_ADDRESS" => "company-address",
|
'SETTINGS::INVOICE:COMPANY_ADDRESS' => 'company-address',
|
||||||
"SETTINGS::INVOICE:COMPANY_PHONE" => "company-phone",
|
'SETTINGS::INVOICE:COMPANY_PHONE' => 'company-phone',
|
||||||
"SETTINGS::INVOICE:COMPANY_MAIL" => "company-mail",
|
'SETTINGS::INVOICE:COMPANY_MAIL' => 'company-mail',
|
||||||
"SETTINGS::INVOICE:COMPANY_VAT" => "company-vat",
|
'SETTINGS::INVOICE:COMPANY_VAT' => 'company-vat',
|
||||||
"SETTINGS::INVOICE:COMPANY_WEBSITE" => "company-web",
|
'SETTINGS::INVOICE:COMPANY_WEBSITE' => 'company-web',
|
||||||
"SETTINGS::INVOICE:PREFIX" => "invoice-prefix",
|
'SETTINGS::INVOICE:PREFIX' => 'invoice-prefix',
|
||||||
"SETTINGS::INVOICE:ENABLED" => "enable-invoices",
|
'SETTINGS::INVOICE:ENABLED' => 'enable-invoices',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
$param = $request->get($value);
|
$param = $request->get($value);
|
||||||
|
|
||||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||||
Cache::forget("setting" . ':' . $key);
|
Cache::forget('setting'.':'.$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->hasFile('logo')) {
|
if ($request->hasFile('logo')) {
|
||||||
$request->file('logo')->storeAs('public', 'logo.png');
|
$request->file('logo')->storeAs('public', 'logo.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect(route('admin.settings.index').'#invoices')->with('success', __('Invoice settings updated!'));
|
||||||
return redirect(route('admin.settings.index') . '#invoices')->with('success', __('Invoice settings updated!'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,12 @@ use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
|
||||||
class Language
|
class Language
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateSettings(Request $request)
|
public function updateSettings(Request $request)
|
||||||
{
|
{
|
||||||
|
@ -28,34 +26,31 @@ class Language
|
||||||
'datatable-language' => 'required|string',
|
'datatable-language' => 'required|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return redirect(route('admin.settings.index') . '#language')->with('error', __('Language settings have not been updated!'))->withErrors($validator);
|
return redirect(route('admin.settings.index').'#language')->with('error', __('Language settings have not been updated!'))->withErrors($validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||||
"SETTINGS::LOCALE:DEFAULT" => "defaultLanguage",
|
'SETTINGS::LOCALE:DEFAULT' => 'defaultLanguage',
|
||||||
"SETTINGS::LOCALE:DYNAMIC" => "autotranslate",
|
'SETTINGS::LOCALE:DYNAMIC' => 'autotranslate',
|
||||||
"SETTINGS::LOCALE:CLIENTS_CAN_CHANGE" => "canClientChangeLanguage",
|
'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE' => 'canClientChangeLanguage',
|
||||||
"SETTINGS::LOCALE:AVAILABLE" => "languages",
|
'SETTINGS::LOCALE:AVAILABLE' => 'languages',
|
||||||
"SETTINGS::LOCALE:DATATABLES" => "datatable-language"
|
'SETTINGS::LOCALE:DATATABLES' => 'datatable-language',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
$param = $request->get($value);
|
$param = $request->get($value);
|
||||||
|
|
||||||
if (is_array($param)) {
|
if (is_array($param)) {
|
||||||
$param = implode(",", $param);
|
$param = implode(',', $param);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||||
Cache::forget("setting" . ':' . $key);
|
Cache::forget('setting'.':'.$key);
|
||||||
Session::remove("locale");
|
Session::remove('locale');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect(route('admin.settings.index').'#language')->with('success', __('Language settings updated!'));
|
||||||
return redirect(route('admin.settings.index') . '#language')->with('success', __('Language settings updated!'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,11 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
|
||||||
class Misc
|
class Misc
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSettings(Request $request)
|
public function updateSettings(Request $request)
|
||||||
|
@ -48,14 +47,14 @@ class Misc
|
||||||
|
|
||||||
$validator->after(function ($validator) use ($request) {
|
$validator->after(function ($validator) use ($request) {
|
||||||
// if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set
|
// if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set
|
||||||
if ($request->get('enable-recaptcha') == 'true' && (!$request->get('recaptcha-site-key') || !$request->get('recaptcha-secret-key'))) {
|
if ($request->get('enable-recaptcha') == 'true' && (! $request->get('recaptcha-site-key') || ! $request->get('recaptcha-secret-key'))) {
|
||||||
$validator->errors()->add('recaptcha-site-key', 'The site key is required if recaptcha is enabled.');
|
$validator->errors()->add('recaptcha-site-key', 'The site key is required if recaptcha is enabled.');
|
||||||
$validator->errors()->add('recaptcha-secret-key', 'The secret key is required if recaptcha is enabled.');
|
$validator->errors()->add('recaptcha-secret-key', 'The secret key is required if recaptcha is enabled.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return redirect(route('admin.settings.index') . '#misc')->with('error', __('Misc settings have not been updated!'))->withErrors($validator)
|
return redirect(route('admin.settings.index').'#misc')->with('error', __('Misc settings have not been updated!'))->withErrors($validator)
|
||||||
->withInput();
|
->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,31 +66,30 @@ class Misc
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
"SETTINGS::DISCORD:BOT_TOKEN" => "discord-bot-token",
|
'SETTINGS::DISCORD:BOT_TOKEN' => 'discord-bot-token',
|
||||||
"SETTINGS::DISCORD:CLIENT_ID" => "discord-client-id",
|
'SETTINGS::DISCORD:CLIENT_ID' => 'discord-client-id',
|
||||||
"SETTINGS::DISCORD:CLIENT_SECRET" => "discord-client-secret",
|
'SETTINGS::DISCORD:CLIENT_SECRET' => 'discord-client-secret',
|
||||||
"SETTINGS::DISCORD:GUILD_ID" => "discord-guild-id",
|
'SETTINGS::DISCORD:GUILD_ID' => 'discord-guild-id',
|
||||||
"SETTINGS::DISCORD:INVITE_URL" => "discord-invite-url",
|
'SETTINGS::DISCORD:INVITE_URL' => 'discord-invite-url',
|
||||||
"SETTINGS::DISCORD:ROLE_ID" => "discord-role-id",
|
'SETTINGS::DISCORD:ROLE_ID' => 'discord-role-id',
|
||||||
"SETTINGS::RECAPTCHA:SITE_KEY" => "recaptcha-site-key",
|
'SETTINGS::RECAPTCHA:SITE_KEY' => 'recaptcha-site-key',
|
||||||
"SETTINGS::RECAPTCHA:SECRET_KEY" => "recaptcha-secret-key",
|
'SETTINGS::RECAPTCHA:SECRET_KEY' => 'recaptcha-secret-key',
|
||||||
"SETTINGS::RECAPTCHA:ENABLED" => "enable-recaptcha",
|
'SETTINGS::RECAPTCHA:ENABLED' => 'enable-recaptcha',
|
||||||
"SETTINGS::MAIL:MAILER" => "mailservice",
|
'SETTINGS::MAIL:MAILER' => 'mailservice',
|
||||||
"SETTINGS::MAIL:HOST" => "mailhost",
|
'SETTINGS::MAIL:HOST' => 'mailhost',
|
||||||
"SETTINGS::MAIL:PORT" => "mailport",
|
'SETTINGS::MAIL:PORT' => 'mailport',
|
||||||
"SETTINGS::MAIL:USERNAME" => "mailusername",
|
'SETTINGS::MAIL:USERNAME' => 'mailusername',
|
||||||
"SETTINGS::MAIL:PASSWORD" => "mailpassword",
|
'SETTINGS::MAIL:PASSWORD' => 'mailpassword',
|
||||||
"SETTINGS::MAIL:ENCRYPTION" => "mailencryption",
|
'SETTINGS::MAIL:ENCRYPTION' => 'mailencryption',
|
||||||
"SETTINGS::MAIL:FROM_ADDRESS" => "mailfromadress",
|
'SETTINGS::MAIL:FROM_ADDRESS' => 'mailfromadress',
|
||||||
"SETTINGS::MAIL:FROM_NAME" => "mailfromname",
|
'SETTINGS::MAIL:FROM_NAME' => 'mailfromname',
|
||||||
"SETTINGS::REFERRAL::ENABLED" => "enable_referral",
|
'SETTINGS::REFERRAL::ENABLED' => 'enable_referral',
|
||||||
"SETTINGS::REFERRAL::REWARD" => "referral_reward",
|
'SETTINGS::REFERRAL::REWARD' => 'referral_reward',
|
||||||
"SETTINGS::REFERRAL::ALLOWED" => "referral_allowed",
|
'SETTINGS::REFERRAL::ALLOWED' => 'referral_allowed',
|
||||||
"SETTINGS::REFERRAL:MODE" => "referral_mode",
|
'SETTINGS::REFERRAL:MODE' => 'referral_mode',
|
||||||
"SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION" => "always_give_commission",
|
'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION' => 'always_give_commission',
|
||||||
"SETTINGS::REFERRAL:PERCENTAGE" => "referral_percentage",
|
'SETTINGS::REFERRAL:PERCENTAGE' => 'referral_percentage',
|
||||||
"SETTINGS::TICKET:ENABLED" => "ticket_enabled"
|
'SETTINGS::TICKET:ENABLED' => 'ticket_enabled',
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -99,10 +97,9 @@ class Misc
|
||||||
$param = $request->get($value);
|
$param = $request->get($value);
|
||||||
|
|
||||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||||
Cache::forget("setting" . ':' . $key);
|
Cache::forget('setting'.':'.$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect(route('admin.settings.index').'#misc')->with('success', __('Misc settings updated!'));
|
||||||
return redirect(route('admin.settings.index') . '#misc')->with('success', __('Misc settings updated!'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,55 +7,52 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
|
||||||
class Payments
|
class Payments
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateSettings(Request $request)
|
public function updateSettings(Request $request)
|
||||||
{
|
{
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->all(), [
|
||||||
"paypal-client_id" => "nullable|string",
|
'paypal-client_id' => 'nullable|string',
|
||||||
"paypal-client-secret" => "nullable|string",
|
'paypal-client-secret' => 'nullable|string',
|
||||||
"paypal-sandbox-secret" => "nullable|string",
|
'paypal-sandbox-secret' => 'nullable|string',
|
||||||
"stripe-secret-key" => "nullable|string",
|
'stripe-secret-key' => 'nullable|string',
|
||||||
"stripe-endpoint-secret" => "nullable|string",
|
'stripe-endpoint-secret' => 'nullable|string',
|
||||||
"stripe-test-secret-key" => "nullable|string",
|
'stripe-test-secret-key' => 'nullable|string',
|
||||||
"stripe-test-endpoint-secret" => "nullable|string",
|
'stripe-test-endpoint-secret' => 'nullable|string',
|
||||||
"stripe-methods" => "nullable|string",
|
'stripe-methods' => 'nullable|string',
|
||||||
"sales-tax" => "nullable|numeric",
|
'sales-tax' => 'nullable|numeric',
|
||||||
]);
|
]);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return redirect(route('admin.settings.index') . '#payment')->with('error', __('Payment settings have not been updated!'))->withErrors($validator)
|
return redirect(route('admin.settings.index').'#payment')->with('error', __('Payment settings have not been updated!'))->withErrors($validator)
|
||||||
->withInput();
|
->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||||
"SETTINGS::PAYMENTS:PAYPAL:SECRET" => "paypal-client-secret",
|
'SETTINGS::PAYMENTS:PAYPAL:SECRET' => 'paypal-client-secret',
|
||||||
"SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID" => "paypal-client-id",
|
'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID' => 'paypal-client-id',
|
||||||
"SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET" => "paypal-sandbox-secret",
|
'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET' => 'paypal-sandbox-secret',
|
||||||
"SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID" => "paypal-sandbox-id",
|
'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID' => 'paypal-sandbox-id',
|
||||||
"SETTINGS::PAYMENTS:STRIPE:SECRET" => "stripe-secret",
|
'SETTINGS::PAYMENTS:STRIPE:SECRET' => 'stripe-secret',
|
||||||
"SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET" => "stripe-endpoint-secret",
|
'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET' => 'stripe-endpoint-secret',
|
||||||
"SETTINGS::PAYMENTS:STRIPE:TEST_SECRET" => "stripe-test-secret",
|
'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET' => 'stripe-test-secret',
|
||||||
"SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET" => "stripe-endpoint-test-secret",
|
'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET' => 'stripe-endpoint-test-secret',
|
||||||
"SETTINGS::PAYMENTS:STRIPE:METHODS" => "stripe-methods",
|
'SETTINGS::PAYMENTS:STRIPE:METHODS' => 'stripe-methods',
|
||||||
"SETTINGS::PAYMENTS:SALES_TAX" => "sales-tax"
|
'SETTINGS::PAYMENTS:SALES_TAX' => 'sales-tax',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
$param = $request->get($value);
|
$param = $request->get($value);
|
||||||
|
|
||||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||||
Cache::forget("setting" . ':' . $key);
|
Cache::forget('setting'.':'.$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('admin.settings.index') . '#payment')->with('success', __('Payment settings updated!'));
|
return redirect(route('admin.settings.index').'#payment')->with('success', __('Payment settings updated!'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,64 +10,66 @@ use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class System
|
class System
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkPteroClientkey(){
|
public function checkPteroClientkey()
|
||||||
|
{
|
||||||
$response = Pterodactyl::getClientUser();
|
$response = Pterodactyl::getClientUser();
|
||||||
|
|
||||||
if ($response->failed()){ return redirect()->back()->with('error', __('Your Key or URL is not correct')); }
|
if ($response->failed()) {
|
||||||
|
return redirect()->back()->with('error', __('Your Key or URL is not correct'));
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Everything is good!'));
|
return redirect()->back()->with('success', __('Everything is good!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSettings(Request $request)
|
public function updateSettings(Request $request)
|
||||||
{
|
{
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->all(), [
|
||||||
"register-ip-check" => "string",
|
'register-ip-check' => 'string',
|
||||||
"server-create-charge-first-hour" => "string",
|
'server-create-charge-first-hour' => 'string',
|
||||||
"credits-display-name" => "required|string",
|
'credits-display-name' => 'required|string',
|
||||||
"allocation-limit" => "required|min:0|integer",
|
'allocation-limit' => 'required|min:0|integer',
|
||||||
"force-email-verification" => "string",
|
'force-email-verification' => 'string',
|
||||||
"force-discord-verification" => "string",
|
'force-discord-verification' => 'string',
|
||||||
"initial-credits" => "required|min:0|integer",
|
'initial-credits' => 'required|min:0|integer',
|
||||||
"initial-server-limit" => "required|min:0|integer",
|
'initial-server-limit' => 'required|min:0|integer',
|
||||||
"credits-reward-amount-discord" => "required|min:0|integer",
|
'credits-reward-amount-discord' => 'required|min:0|integer',
|
||||||
"credits-reward-amount-email" => "required|min:0|integer",
|
'credits-reward-amount-email' => 'required|min:0|integer',
|
||||||
"server-limit-discord" => "required|min:0|integer",
|
'server-limit-discord' => 'required|min:0|integer',
|
||||||
"server-limit-email" => "required|min:0|integer",
|
'server-limit-email' => 'required|min:0|integer',
|
||||||
"server-limit-purchase" => "required|min:0|integer",
|
'server-limit-purchase' => 'required|min:0|integer',
|
||||||
"pterodactyl-api-key" => "required|string",
|
'pterodactyl-api-key' => 'required|string',
|
||||||
"pterodactyl-url" => "required|string",
|
'pterodactyl-url' => 'required|string',
|
||||||
"per-page-limit" => "required|min:0|integer",
|
'per-page-limit' => 'required|min:0|integer',
|
||||||
"pterodactyl-admin-api-key" => "required|string",
|
'pterodactyl-admin-api-key' => 'required|string',
|
||||||
"enable-upgrades" => "string",
|
'enable-upgrades' => 'string',
|
||||||
"enable-disable-servers" => "string",
|
'enable-disable-servers' => 'string',
|
||||||
"show-imprint" => "string",
|
'show-imprint' => 'string',
|
||||||
"show-privacy" => "string",
|
'show-privacy' => 'string',
|
||||||
"show-tos" => "string",
|
'show-tos' => 'string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$validator->after(function ($validator) use ($request) {
|
$validator->after(function ($validator) use ($request) {
|
||||||
// if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set
|
// if enable-recaptcha is true then recaptcha-site-key and recaptcha-secret-key must be set
|
||||||
if ($request->get('enable-upgrades') == 'true' && (!$request->get('pterodactyl-admin-api-key'))) {
|
if ($request->get('enable-upgrades') == 'true' && (! $request->get('pterodactyl-admin-api-key'))) {
|
||||||
$validator->errors()->add('pterodactyl-admin-api-key', 'The admin api key is required when upgrades are enabled.');
|
$validator->errors()->add('pterodactyl-admin-api-key', 'The admin api key is required when upgrades are enabled.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return redirect(route('admin.settings.index') . '#system')->with('error', __('System settings have not been updated!'))->withErrors($validator)
|
return redirect(route('admin.settings.index').'#system')->with('error', __('System settings have not been updated!'))->withErrors($validator)
|
||||||
->withInput();
|
->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update Icons from request
|
// update Icons from request
|
||||||
$this->updateIcons($request);
|
$this->updateIcons($request);
|
||||||
|
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
|
|
||||||
"SETTINGS::SYSTEM:REGISTER_IP_CHECK" => "register-ip-check",
|
"SETTINGS::SYSTEM:REGISTER_IP_CHECK" => "register-ip-check",
|
||||||
"SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR" => "server-create-charge-first-hour",
|
"SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR" => "server-create-charge-first-hour",
|
||||||
"SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME" => "credits-display-name",
|
"SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME" => "credits-display-name",
|
||||||
|
@ -96,16 +98,15 @@ public function checkPteroClientkey(){
|
||||||
"SETTINGS::SYSTEM:SHOW_TOS" => "show-tos",
|
"SETTINGS::SYSTEM:SHOW_TOS" => "show-tos",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
$param = $request->get($value);
|
$param = $request->get($value);
|
||||||
|
|
||||||
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
|
||||||
Cache::forget("setting" . ':' . $key);
|
Cache::forget('setting'.':'.$key);
|
||||||
}
|
|
||||||
return redirect(route('admin.settings.index') . '#system')->with('success', __('System settings updated!'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect(route('admin.settings.index').'#system')->with('success', __('System settings updated!'));
|
||||||
|
}
|
||||||
|
|
||||||
private function updateIcons(Request $request)
|
private function updateIcons(Request $request)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,9 +24,9 @@ class ChargeCreditsCommand extends Command
|
||||||
*/
|
*/
|
||||||
protected $description = 'Charge all users with active servers';
|
protected $description = 'Charge all users with active servers';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of users that have to be notified
|
* A list of users that have to be notified
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $usersToNotify = [];
|
protected $usersToNotify = [];
|
||||||
|
@ -56,24 +56,23 @@ class ChargeCreditsCommand extends Command
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $server->user;
|
$user = $server->user;
|
||||||
|
|
||||||
#charge credits / suspend server
|
//charge credits / suspend server
|
||||||
if ($user->credits >= $product->getHourlyPrice()) {
|
if ($user->credits >= $product->getHourlyPrice()) {
|
||||||
$this->line("<fg=blue>{$user->name}</> Current credits: <fg=green>{$user->credits}</> Credits to be removed: <fg=red>{$product->getHourlyPrice()}</>");
|
$this->line("<fg=blue>{$user->name}</> Current credits: <fg=green>{$user->credits}</> Credits to be removed: <fg=red>{$product->getHourlyPrice()}</>");
|
||||||
$user->decrement('credits', $product->getHourlyPrice());
|
$user->decrement('credits', $product->getHourlyPrice());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
#suspend server
|
//suspend server
|
||||||
$this->line("<fg=yellow>{$server->name}</> from user: <fg=blue>{$user->name}</> has been <fg=red>suspended!</>");
|
$this->line("<fg=yellow>{$server->name}</> from user: <fg=blue>{$user->name}</> has been <fg=red>suspended!</>");
|
||||||
$server->suspend();
|
$server->suspend();
|
||||||
|
|
||||||
#add user to notify list
|
//add user to notify list
|
||||||
if (!in_array($user, $this->usersToNotify)) {
|
if (! in_array($user, $this->usersToNotify)) {
|
||||||
array_push($this->usersToNotify, $user);
|
array_push($this->usersToNotify, $user);
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$this->error($exception->getMessage());
|
$this->error($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -86,7 +85,7 @@ class ChargeCreditsCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function notifyUsers()
|
public function notifyUsers()
|
||||||
{
|
{
|
||||||
if (!empty($this->usersToNotify)) {
|
if (! empty($this->usersToNotify)) {
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
foreach ($this->usersToNotify as $user) {
|
foreach ($this->usersToNotify as $user) {
|
||||||
$this->line("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");
|
$this->line("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");
|
||||||
|
@ -94,8 +93,9 @@ class ChargeCreditsCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#reset array
|
//reset array
|
||||||
$this->usersToNotify = array();
|
$this->usersToNotify = [];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ class ImportUsersFromPteroCommand extends Command
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $importFileName = 'users.json';
|
private $importFileName = 'users.json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
|
@ -39,25 +40,28 @@ class ImportUsersFromPteroCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
//check if json file exists
|
//check if json file exists
|
||||||
if (!Storage::disk('local')->exists('users.json')) {
|
if (! Storage::disk('local')->exists('users.json')) {
|
||||||
$this->error('[ERROR] ' . storage_path('app') . '/' . $this->importFileName . ' is missing');
|
$this->error('[ERROR] '.storage_path('app').'/'.$this->importFileName.' is missing');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if json file is valid
|
//check if json file is valid
|
||||||
$json = json_decode(Storage::disk('local')->get('users.json'));
|
$json = json_decode(Storage::disk('local')->get('users.json'));
|
||||||
if (!array_key_exists(2, $json)) {
|
if (! array_key_exists(2, $json)) {
|
||||||
$this->error('[ERROR] Invalid json file');
|
$this->error('[ERROR] Invalid json file');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$json[2]->data) {
|
if (! $json[2]->data) {
|
||||||
$this->error('[ERROR] Invalid json file / No users found!');
|
$this->error('[ERROR] Invalid json file / No users found!');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,12 +73,14 @@ class ImportUsersFromPteroCommand extends Command
|
||||||
//cancel
|
//cancel
|
||||||
if ($confirm !== 'y') {
|
if ($confirm !== 'y') {
|
||||||
$this->error('[ERROR] Stopped import script!');
|
$this->error('[ERROR] Stopped import script!');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//import users
|
//import users
|
||||||
$this->deleteCurrentUserBase();
|
$this->deleteCurrentUserBase();
|
||||||
$this->importUsingJsonFile($json, $initial_credits, $initial_server_limit);
|
$this->importUsingJsonFile($json, $initial_credits, $initial_server_limit);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +90,9 @@ class ImportUsersFromPteroCommand extends Command
|
||||||
private function deleteCurrentUserBase()
|
private function deleteCurrentUserBase()
|
||||||
{
|
{
|
||||||
$currentUserCount = User::count();
|
$currentUserCount = User::count();
|
||||||
if ($currentUserCount == 0) return;
|
if ($currentUserCount == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->line("Deleting ({$currentUserCount}) users..");
|
$this->line("Deleting ({$currentUserCount}) users..");
|
||||||
foreach (User::all() as $user) {
|
foreach (User::all() as $user) {
|
||||||
|
@ -104,20 +112,20 @@ class ImportUsersFromPteroCommand extends Command
|
||||||
$role = $user->root_admin == '0' ? 'member' : 'admin';
|
$role = $user->root_admin == '0' ? 'member' : 'admin';
|
||||||
|
|
||||||
User::create([
|
User::create([
|
||||||
"pterodactyl_id" => $user->id,
|
'pterodactyl_id' => $user->id,
|
||||||
"name" => $user->name_first,
|
'name' => $user->name_first,
|
||||||
"email" => $user->email,
|
'email' => $user->email,
|
||||||
"password" => $user->password,
|
'password' => $user->password,
|
||||||
"role" => $role,
|
'role' => $role,
|
||||||
"credits" => $initial_credits,
|
'credits' => $initial_credits,
|
||||||
"server_limit" => $initial_server_limit,
|
'server_limit' => $initial_server_limit,
|
||||||
"created_at" => $user->created_at,
|
'created_at' => $user->created_at,
|
||||||
"updated_at" => $user->updated_at,
|
'updated_at' => $user->updated_at,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->newLine();
|
$this->newLine();
|
||||||
$this->line("Done importing, you can now login using your pterodactyl credentials.");
|
$this->line('Done importing, you can now login using your pterodactyl credentials.');
|
||||||
$this->newLine();
|
$this->newLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ use App\Models\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
|
|
||||||
class MakeUserCommand extends Command
|
class MakeUserCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -59,6 +58,7 @@ class MakeUserCommand extends Command
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$this->error($validator->errors()->first());
|
$this->error($validator->errors()->first());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,16 @@ class MakeUserCommand extends Command
|
||||||
$response = $this->pterodactyl->getUser($ptero_id);
|
$response = $this->pterodactyl->getUser($ptero_id);
|
||||||
|
|
||||||
if (isset($response['errors'])) {
|
if (isset($response['errors'])) {
|
||||||
if (isset($response['errors'][0]['code'])) $this->error("code: {$response['errors'][0]['code']}");
|
if (isset($response['errors'][0]['code'])) {
|
||||||
if (isset($response['errors'][0]['status'])) $this->error("status: {$response['errors'][0]['status']}");
|
$this->error("code: {$response['errors'][0]['code']}");
|
||||||
if (isset($response['errors'][0]['detail'])) $this->error("detail: {$response['errors'][0]['detail']}");
|
}
|
||||||
|
if (isset($response['errors'][0]['status'])) {
|
||||||
|
$this->error("status: {$response['errors'][0]['status']}");
|
||||||
|
}
|
||||||
|
if (isset($response['errors'][0]['detail'])) {
|
||||||
|
$this->error("detail: {$response['errors'][0]['detail']}");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +84,7 @@ class MakeUserCommand extends Command
|
||||||
'email' => $response['email'],
|
'email' => $response['email'],
|
||||||
'role' => 'admin',
|
'role' => 'admin',
|
||||||
'password' => Hash::make($password),
|
'password' => Hash::make($password),
|
||||||
'pterodactyl_id' => $response['id']
|
'pterodactyl_id' => $response['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->table(['Field', 'Value'], [
|
$this->table(['Field', 'Value'], [
|
||||||
|
|
|
@ -42,6 +42,7 @@ class notify extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
User::findOrFail($this->argument('id'))->notify(new ServerCreationError(Server::all()[0]));
|
User::findOrFail($this->argument('id'))->notify(new ServerCreationError(Server::all()[0]));
|
||||||
|
|
||||||
return 'message send';
|
return 'message send';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Symfony\Component\Process\Process;
|
use Illuminate\Console\Command;
|
||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
class update extends Command
|
class update extends Command
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ class update extends Command
|
||||||
$this->output->warning('This command does just pull the newest changes from the github repo. Verify the github repo before running this');
|
$this->output->warning('This command does just pull the newest changes from the github repo. Verify the github repo before running this');
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '8.0.0') < 0) {
|
if (version_compare(PHP_VERSION, '8.0.0') < 0) {
|
||||||
$this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 8.0.0, you have [' . PHP_VERSION . '].');
|
$this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 8.0.0, you have ['.PHP_VERSION.'].');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = 'www-data';
|
$user = 'www-data';
|
||||||
|
@ -55,7 +55,7 @@ class update extends Command
|
||||||
$userDetails = posix_getpwuid(fileowner('public'));
|
$userDetails = posix_getpwuid(fileowner('public'));
|
||||||
$user = $userDetails['name'] ?? 'www-data';
|
$user = $userDetails['name'] ?? 'www-data';
|
||||||
|
|
||||||
if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
|
if (! $this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
|
||||||
$user = $this->anticipate(
|
$user = $this->anticipate(
|
||||||
'Please enter the name of the user running your webserver process. This varies from system to system, but is generally "www-data", "nginx", or "apache".',
|
'Please enter the name of the user running your webserver process. This varies from system to system, but is generally "www-data", "nginx", or "apache".',
|
||||||
[
|
[
|
||||||
|
@ -71,7 +71,7 @@ class update extends Command
|
||||||
$groupDetails = posix_getgrgid(filegroup('public'));
|
$groupDetails = posix_getgrgid(filegroup('public'));
|
||||||
$group = $groupDetails['name'] ?? 'www-data';
|
$group = $groupDetails['name'] ?? 'www-data';
|
||||||
|
|
||||||
if (!$this->confirm("Your webserver group has been detected as [{$group}]: is this correct?", true)) {
|
if (! $this->confirm("Your webserver group has been detected as [{$group}]: is this correct?", true)) {
|
||||||
$group = $this->anticipate(
|
$group = $this->anticipate(
|
||||||
'Please enter the name of the group running your webserver process. Normally this is the same as your user.',
|
'Please enter the name of the group running your webserver process. Normally this is the same as your user.',
|
||||||
[
|
[
|
||||||
|
@ -85,24 +85,21 @@ class update extends Command
|
||||||
|
|
||||||
ini_set('output_buffering', 0);
|
ini_set('output_buffering', 0);
|
||||||
|
|
||||||
if (!$this->confirm('Are you sure you want to run the upgrade process for your Dashboard?')) {
|
if (! $this->confirm('Are you sure you want to run the upgrade process for your Dashboard?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$bar = $this->output->createProgressBar(9);
|
$bar = $this->output->createProgressBar(9);
|
||||||
$bar->start();
|
$bar->start();
|
||||||
|
|
||||||
|
|
||||||
$this->withProgress($bar, function () {
|
$this->withProgress($bar, function () {
|
||||||
$this->line("\$upgrader> git pull");
|
$this->line('$upgrader> git pull');
|
||||||
$process = Process::fromShellCommandline("git pull");
|
$process = Process::fromShellCommandline('git pull');
|
||||||
$process->run(function ($type, $buffer) {
|
$process->run(function ($type, $buffer) {
|
||||||
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
|
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$this->withProgress($bar, function () {
|
$this->withProgress($bar, function () {
|
||||||
$this->line('$upgrader> php artisan down');
|
$this->line('$upgrader> php artisan down');
|
||||||
$this->call('down');
|
$this->call('down');
|
||||||
|
@ -118,12 +115,12 @@ class update extends Command
|
||||||
|
|
||||||
$this->withProgress($bar, function () {
|
$this->withProgress($bar, function () {
|
||||||
$command = ['composer', 'install', '--no-ansi'];
|
$command = ['composer', 'install', '--no-ansi'];
|
||||||
if (config('app.env') === 'production' && !config('app.debug')) {
|
if (config('app.env') === 'production' && ! config('app.debug')) {
|
||||||
$command[] = '--optimize-autoloader';
|
$command[] = '--optimize-autoloader';
|
||||||
$command[] = '--no-dev';
|
$command[] = '--no-dev';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->line('$upgrader> ' . implode(' ', $command));
|
$this->line('$upgrader> '.implode(' ', $command));
|
||||||
$process = new Process($command);
|
$process = new Process($command);
|
||||||
$process->setTimeout(10 * 60);
|
$process->setTimeout(10 * 60);
|
||||||
$process->run(function ($type, $buffer) {
|
$process->run(function ($type, $buffer) {
|
||||||
|
@ -162,9 +159,8 @@ class update extends Command
|
||||||
|
|
||||||
$this->newLine();
|
$this->newLine();
|
||||||
$this->info('Finished running upgrade.');
|
$this->info('Finished running upgrade.');
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function withProgress(ProgressBar $bar, Closure $callback)
|
protected function withProgress(ProgressBar $bar, Closure $callback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,15 +8,6 @@ use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The Artisan commands provided by your application.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $commands = [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the application's command schedule.
|
* Define the application's command schedule.
|
||||||
*
|
*
|
||||||
|
@ -29,7 +20,7 @@ class Kernel extends ConsoleKernel
|
||||||
|
|
||||||
//log cronjob activity
|
//log cronjob activity
|
||||||
$schedule->call(function () {
|
$schedule->call(function () {
|
||||||
Storage::disk('logs')->put('cron.log' , "Last activity from cronjobs - " . now());
|
Storage::disk('logs')->put('cron.log', 'Last activity from cronjobs - '.now());
|
||||||
})->everyMinute();
|
})->everyMinute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +31,7 @@ class Kernel extends ConsoleKernel
|
||||||
*/
|
*/
|
||||||
protected function commands()
|
protected function commands()
|
||||||
{
|
{
|
||||||
$this->load(__DIR__ . '/Commands');
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
require base_path('routes/console.php');
|
require base_path('routes/console.php');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,7 @@
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Broadcasting\Channel;
|
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Broadcasting\PresenceChannel;
|
|
||||||
use Illuminate\Broadcasting\PrivateChannel;
|
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,31 @@ use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* A list of exception types with their corresponding custom log levels.
|
||||||
|
*
|
||||||
|
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||||
|
*/
|
||||||
|
protected $levels = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the exception types that are not reported.
|
* A list of the exception types that are not reported.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, class-string<\Throwable>>
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
//
|
//
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the inputs that are never flashed for validation exceptions.
|
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $dontFlash = [
|
protected $dontFlash = [
|
||||||
|
'current_password',
|
||||||
'password',
|
'password',
|
||||||
'password_confirmation',
|
'password_confirmation',
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,17 +24,16 @@ class ActivityLogController extends Controller
|
||||||
$cronLogs = Storage::disk('logs')->exists('cron.log') ? Storage::disk('logs')->get('cron.log') : null;
|
$cronLogs = Storage::disk('logs')->exists('cron.log') ? Storage::disk('logs')->get('cron.log') : null;
|
||||||
|
|
||||||
if ($request->input('search')) {
|
if ($request->input('search')) {
|
||||||
$query = Activity::whereHasMorph('causer' , [User::class] , function($query) use ($request) {
|
$query = Activity::whereHasMorph('causer', [User::class], function ($query) use ($request) {
|
||||||
$query->where('name', 'like' , "%{$request->input('search')}%");
|
$query->where('name', 'like', "%{$request->input('search')}%");
|
||||||
})->orderBy('created_at' , 'desc')->paginate(20);
|
})->orderBy('created_at', 'desc')->paginate(20);
|
||||||
} else {
|
} else {
|
||||||
$query = Activity::orderBy('created_at' , 'desc')->paginate(20);
|
$query = Activity::orderBy('created_at', 'desc')->paginate(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return view('admin.activitylogs.index')->with([
|
return view('admin.activitylogs.index')->with([
|
||||||
'logs' => $query,
|
'logs' => $query,
|
||||||
'cronlogs' => $cronLogs
|
'cronlogs' => $cronLogs,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class ApplicationApiController extends Controller
|
class ApplicationApiController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -45,11 +44,11 @@ class ApplicationApiController extends Controller
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'memo' => 'nullable|string|max:60'
|
'memo' => 'nullable|string|max:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ApplicationApi::create([
|
ApplicationApi::create([
|
||||||
'memo' => $request->input('memo')
|
'memo' => $request->input('memo'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('admin.api.index')->with('success', __('api key created!'));
|
return redirect()->route('admin.api.index')->with('success', __('api key created!'));
|
||||||
|
@ -74,8 +73,8 @@ class ApplicationApiController extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit(ApplicationApi $applicationApi)
|
public function edit(ApplicationApi $applicationApi)
|
||||||
{
|
{
|
||||||
return view('admin.api.edit' , [
|
return view('admin.api.edit', [
|
||||||
'applicationApi' => $applicationApi
|
'applicationApi' => $applicationApi,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ class ApplicationApiController extends Controller
|
||||||
public function update(Request $request, ApplicationApi $applicationApi)
|
public function update(Request $request, ApplicationApi $applicationApi)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'memo' => 'nullable|string|max:60'
|
'memo' => 'nullable|string|max:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$applicationApi->update($request->all());
|
$applicationApi->update($request->all());
|
||||||
|
@ -106,12 +105,14 @@ class ApplicationApiController extends Controller
|
||||||
public function destroy(ApplicationApi $applicationApi)
|
public function destroy(ApplicationApi $applicationApi)
|
||||||
{
|
{
|
||||||
$applicationApi->delete();
|
$applicationApi->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('api key has been removed!'));
|
return redirect()->back()->with('success', __('api key has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse|mixed
|
* @return JsonResponse|mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dataTable(Request $request)
|
public function dataTable(Request $request)
|
||||||
|
@ -121,21 +122,21 @@ class ApplicationApiController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (ApplicationApi $apiKey) {
|
->addColumn('actions', function (ApplicationApi $apiKey) {
|
||||||
return '
|
return '
|
||||||
<a data-content="'.__("Edit").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.api.edit', $apiKey->token) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.api.edit', $apiKey->token).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.api.destroy', $apiKey->token) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.api.destroy', $apiKey->token).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->editColumn('token' , function (ApplicationApi $apiKey) {
|
->editColumn('token', function (ApplicationApi $apiKey) {
|
||||||
return "<code>{$apiKey->token}</code>";
|
return "<code>{$apiKey->token}</code>";
|
||||||
})
|
})
|
||||||
->editColumn('last_used' , function (ApplicationApi $apiKey) {
|
->editColumn('last_used', function (ApplicationApi $apiKey) {
|
||||||
return $apiKey->last_used ? $apiKey->last_used->diffForHumans() : '';
|
return $apiKey->last_used ? $apiKey->last_used->diffForHumans() : '';
|
||||||
})
|
})
|
||||||
->rawColumns(['actions' , 'token'])
|
->rawColumns(['actions', 'token'])
|
||||||
->make();
|
->make();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,14 @@ use ZipArchive;
|
||||||
|
|
||||||
class InvoiceController extends Controller
|
class InvoiceController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function downloadAllInvoices()
|
public function downloadAllInvoices()
|
||||||
{
|
{
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
$zip_safe_path = storage_path('invoices.zip');
|
$zip_safe_path = storage_path('invoices.zip');
|
||||||
$res = $zip->open($zip_safe_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
$res = $zip->open($zip_safe_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||||
$result = $this::rglob(storage_path('app/invoice/*'));
|
$result = $this::rglob(storage_path('app/invoice/*'));
|
||||||
if ($res === TRUE) {
|
if ($res === true) {
|
||||||
$zip->addFromString("1. Info.txt", __("Created at") . " " . now()->format("d.m.Y"));
|
$zip->addFromString('1. Info.txt', __('Created at').' '.now()->format('d.m.Y'));
|
||||||
foreach ($result as $file) {
|
foreach ($result as $file) {
|
||||||
if (file_exists($file) && is_file($file)) {
|
if (file_exists($file) && is_file($file)) {
|
||||||
$zip->addFile($file, basename($file));
|
$zip->addFile($file, basename($file));
|
||||||
|
@ -26,6 +25,7 @@ class InvoiceController extends Controller
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->download($zip_safe_path);
|
return response()->download($zip_safe_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ class InvoiceController extends Controller
|
||||||
public function rglob($pattern, $flags = 0)
|
public function rglob($pattern, $flags = 0)
|
||||||
{
|
{
|
||||||
$files = glob($pattern, $flags);
|
$files = glob($pattern, $flags);
|
||||||
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||||
$files = array_merge($files, $this::rglob($dir . '/' . basename($pattern), $flags));
|
$files = array_merge($files, $this::rglob($dir.'/'.basename($pattern), $flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,16 +54,15 @@ class InvoiceController extends Controller
|
||||||
try {
|
try {
|
||||||
$query = Invoice::where('payment_id', '=', $id)->firstOrFail();
|
$query = Invoice::where('payment_id', '=', $id)->firstOrFail();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
return redirect()->back()->with("error", __("Error!"));
|
return redirect()->back()->with('error', __('Error!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice_path = storage_path('app/invoice/' . $query->invoice_user . '/' . $query->created_at->format("Y") . '/' . $query->invoice_name . '.pdf');
|
$invoice_path = storage_path('app/invoice/'.$query->invoice_user.'/'.$query->created_at->format('Y').'/'.$query->invoice_name.'.pdf');
|
||||||
|
|
||||||
if (!file_exists($invoice_path)) {
|
if (! file_exists($invoice_path)) {
|
||||||
return redirect()->back()->with("error", __("Invoice does not exist on filesystem!"));
|
return redirect()->back()->with('error', __('Invoice does not exist on filesystem!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return response()->download($invoice_path);
|
return response()->download($invoice_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,17 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Classes\Pterodactyl;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Nest;
|
use App\Models\Nest;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use App\Classes\Pterodactyl;
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
|
use App\Models\Server;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
|
use App\Models\User;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class OverViewController extends Controller
|
class OverViewController extends Controller
|
||||||
|
@ -26,7 +25,7 @@ class OverViewController extends Controller
|
||||||
$counters = collect();
|
$counters = collect();
|
||||||
//Set basic variables in the collection
|
//Set basic variables in the collection
|
||||||
$counters->put('users', User::query()->count());
|
$counters->put('users', User::query()->count());
|
||||||
$counters->put('credits', number_format(User::query()->where("role","!=","admin")->sum('credits'), 2, '.', ''));
|
$counters->put('credits', number_format(User::query()->where('role', '!=', 'admin')->sum('credits'), 2, '.', ''));
|
||||||
$counters->put('payments', Payment::query()->count());
|
$counters->put('payments', Payment::query()->count());
|
||||||
$counters->put('eggs', Egg::query()->count());
|
$counters->put('eggs', Egg::query()->count());
|
||||||
$counters->put('nests', Nest::query()->count());
|
$counters->put('nests', Nest::query()->count());
|
||||||
|
@ -49,6 +48,7 @@ class OverViewController extends Controller
|
||||||
$counters['payments']->put('thisMonth', collect());
|
$counters['payments']->put('thisMonth', collect());
|
||||||
$counters['payments']->put('lastMonth', collect());
|
$counters['payments']->put('lastMonth', collect());
|
||||||
|
|
||||||
|
|
||||||
//Prepare subCollection 'taxPayments'
|
//Prepare subCollection 'taxPayments'
|
||||||
$counters->put('taxPayments', collect());
|
$counters->put('taxPayments', collect());
|
||||||
//Get and save taxPayments from last 2 years for later filtering and looping
|
//Get and save taxPayments from last 2 years for later filtering and looping
|
||||||
|
@ -57,27 +57,26 @@ class OverViewController extends Controller
|
||||||
$counters['taxPayments']->put('thisYear', collect());
|
$counters['taxPayments']->put('thisYear', collect());
|
||||||
$counters['taxPayments']->put('lastYear', collect());
|
$counters['taxPayments']->put('lastYear', collect());
|
||||||
|
|
||||||
|
|
||||||
//Fill out variables for each currency separately
|
//Fill out variables for each currency separately
|
||||||
foreach($payments->where('created_at', '>=', Carbon::today()->startOfMonth()) as $payment){
|
foreach ($payments->where('created_at', '>=', Carbon::today()->startOfMonth()) as $payment) {
|
||||||
$paymentCurrency = $payment->currency_code;
|
$paymentCurrency = $payment->currency_code;
|
||||||
if(!isset($counters['payments']['thisMonth'][$paymentCurrency])){
|
if (! isset($counters['payments']['thisMonth'][$paymentCurrency])) {
|
||||||
$counters['payments']['thisMonth']->put($paymentCurrency, collect());
|
$counters['payments']['thisMonth']->put($paymentCurrency, collect());
|
||||||
$counters['payments']['thisMonth'][$paymentCurrency]->total = 0;
|
$counters['payments']['thisMonth'][$paymentCurrency]->total = 0;
|
||||||
$counters['payments']['thisMonth'][$paymentCurrency]->count = 0;
|
$counters['payments']['thisMonth'][$paymentCurrency]->count = 0;
|
||||||
}
|
}
|
||||||
$counters['payments']['thisMonth'][$paymentCurrency]->total += $payment->total_price;
|
$counters['payments']['thisMonth'][$paymentCurrency]->total += $payment->total_price;
|
||||||
$counters['payments']['thisMonth'][$paymentCurrency]->count ++;
|
$counters['payments']['thisMonth'][$paymentCurrency]->count++;
|
||||||
}
|
}
|
||||||
foreach($payments->where('created_at', '<', Carbon::today()->startOfMonth()) as $payment){
|
foreach ($payments->where('created_at', '<', Carbon::today()->startOfMonth()) as $payment) {
|
||||||
$paymentCurrency = $payment->currency_code;
|
$paymentCurrency = $payment->currency_code;
|
||||||
if(!isset($counters['payments']['lastMonth'][$paymentCurrency])){
|
if (! isset($counters['payments']['lastMonth'][$paymentCurrency])) {
|
||||||
$counters['payments']['lastMonth']->put($paymentCurrency, collect());
|
$counters['payments']['lastMonth']->put($paymentCurrency, collect());
|
||||||
$counters['payments']['lastMonth'][$paymentCurrency]->total = 0;
|
$counters['payments']['lastMonth'][$paymentCurrency]->total = 0;
|
||||||
$counters['payments']['lastMonth'][$paymentCurrency]->count = 0;
|
$counters['payments']['lastMonth'][$paymentCurrency]->count = 0;
|
||||||
}
|
}
|
||||||
$counters['payments']['lastMonth'][$paymentCurrency]->total += $payment->total_price;
|
$counters['payments']['lastMonth'][$paymentCurrency]->total += $payment->total_price;
|
||||||
$counters['payments']['lastMonth'][$paymentCurrency]->count ++;
|
$counters['payments']['lastMonth'][$paymentCurrency]->count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sort currencies alphabetically and set some additional variables
|
//sort currencies alphabetically and set some additional variables
|
||||||
|
@ -89,9 +88,11 @@ class OverViewController extends Controller
|
||||||
$counters['payments']['lastMonth']->timeEnd = Carbon::today()->endOfMonth()->subMonth()->toDateString();
|
$counters['payments']['lastMonth']->timeEnd = Carbon::today()->endOfMonth()->subMonth()->toDateString();
|
||||||
$counters['payments']->total = Payment::query()->count();
|
$counters['payments']->total = Payment::query()->count();
|
||||||
|
|
||||||
|
|
||||||
foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()) as $taxPayment){
|
foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()) as $taxPayment){
|
||||||
$paymentCurrency = $taxPayment->currency_code;
|
$paymentCurrency = $taxPayment->currency_code;
|
||||||
if(!isset($counters['taxPayments']['thisYear'][$paymentCurrency])){
|
if(!isset($counters['taxPayments']['thisYear'][$paymentCurrency])){
|
||||||
|
|
||||||
$counters['taxPayments']['thisYear']->put($paymentCurrency, collect());
|
$counters['taxPayments']['thisYear']->put($paymentCurrency, collect());
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->total = 0;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->total = 0;
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->count = 0;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->count = 0;
|
||||||
|
@ -99,13 +100,15 @@ class OverViewController extends Controller
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->taxes = 0;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->taxes = 0;
|
||||||
}
|
}
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->total += $taxPayment->total_price;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->total += $taxPayment->total_price;
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->count ++;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->count++;
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->price += $taxPayment->price;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->price += $taxPayment->price;
|
||||||
$counters['taxPayments']['thisYear'][$paymentCurrency]->taxes += $taxPayment->tax_value;
|
$counters['taxPayments']['thisYear'][$paymentCurrency]->taxes += $taxPayment->tax_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()->subYear())->where('created_at', '<', Carbon::today()->startOfYear()) as $taxPayment){
|
foreach($taxPayments->where('created_at', '>=', Carbon::today()->startOfYear()->subYear())->where('created_at', '<', Carbon::today()->startOfYear()) as $taxPayment){
|
||||||
$paymentCurrency = $taxPayment->currency_code;
|
$paymentCurrency = $taxPayment->currency_code;
|
||||||
if(!isset($counters['taxPayments']['lastYear'][$paymentCurrency])){
|
if(!isset($counters['taxPayments']['lastYear'][$paymentCurrency])){
|
||||||
|
|
||||||
$counters['taxPayments']['lastYear']->put($paymentCurrency, collect());
|
$counters['taxPayments']['lastYear']->put($paymentCurrency, collect());
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->total = 0;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->total = 0;
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->count = 0;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->count = 0;
|
||||||
|
@ -113,7 +116,7 @@ class OverViewController extends Controller
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->taxes = 0;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->taxes = 0;
|
||||||
}
|
}
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->total += $taxPayment->total_price;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->total += $taxPayment->total_price;
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->count ++;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->count++;
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->price += $taxPayment->price;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->price += $taxPayment->price;
|
||||||
$counters['taxPayments']['lastYear'][$paymentCurrency]->taxes += $taxPayment->tax_value;
|
$counters['taxPayments']['lastYear'][$paymentCurrency]->taxes += $taxPayment->tax_value;
|
||||||
}
|
}
|
||||||
|
@ -129,21 +132,21 @@ class OverViewController extends Controller
|
||||||
$lastEgg = Egg::query()->latest('updated_at')->first();
|
$lastEgg = Egg::query()->latest('updated_at')->first();
|
||||||
$syncLastUpdate = $lastEgg ? $lastEgg->updated_at->isoFormat('LLL') : __('unknown');
|
$syncLastUpdate = $lastEgg ? $lastEgg->updated_at->isoFormat('LLL') : __('unknown');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Get node information and prepare collection
|
//Get node information and prepare collection
|
||||||
$pteroNodeIds = [];
|
$pteroNodeIds = [];
|
||||||
foreach(Pterodactyl::getNodes() as $pteroNode){
|
foreach (Pterodactyl::getNodes() as $pteroNode) {
|
||||||
array_push($pteroNodeIds, $pteroNode['attributes']['id']);
|
array_push($pteroNodeIds, $pteroNode['attributes']['id']);
|
||||||
}
|
}
|
||||||
$nodes = collect();
|
$nodes = collect();
|
||||||
foreach($DBnodes = Node::query()->get() as $DBnode){ //gets all node information and prepares the structure
|
foreach ($DBnodes = Node::query()->get() as $DBnode) { //gets all node information and prepares the structure
|
||||||
$nodeId = $DBnode['id'];
|
$nodeId = $DBnode['id'];
|
||||||
if(!in_array($nodeId, $pteroNodeIds)) continue; //Check if node exists on pterodactyl too, if not, skip
|
if (! in_array($nodeId, $pteroNodeIds)) {
|
||||||
|
continue;
|
||||||
|
} //Check if node exists on pterodactyl too, if not, skip
|
||||||
$nodes->put($nodeId, collect());
|
$nodes->put($nodeId, collect());
|
||||||
$nodes[$nodeId]->name = $DBnode['name'];
|
$nodes[$nodeId]->name = $DBnode['name'];
|
||||||
$pteroNode = Pterodactyl::getNode($nodeId);
|
$pteroNode = Pterodactyl::getNode($nodeId);
|
||||||
$nodes[$nodeId]->usagePercent = round(max($pteroNode['allocated_resources']['memory']/($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100), $pteroNode['allocated_resources']['disk']/($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100))*100, 2);
|
$nodes[$nodeId]->usagePercent = round(max($pteroNode['allocated_resources']['memory'] / ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100), $pteroNode['allocated_resources']['disk'] / ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100)) * 100, 2);
|
||||||
$counters['totalUsagePercent'] += $nodes[$nodeId]->usagePercent;
|
$counters['totalUsagePercent'] += $nodes[$nodeId]->usagePercent;
|
||||||
|
|
||||||
$nodes[$nodeId]->totalServers = 0;
|
$nodes[$nodeId]->totalServers = 0;
|
||||||
|
@ -151,31 +154,29 @@ class OverViewController extends Controller
|
||||||
$nodes[$nodeId]->totalEarnings = 0;
|
$nodes[$nodeId]->totalEarnings = 0;
|
||||||
$nodes[$nodeId]->activeEarnings = 0;
|
$nodes[$nodeId]->activeEarnings = 0;
|
||||||
}
|
}
|
||||||
$counters['totalUsagePercent'] = ($DBnodes->count())?round($counters['totalUsagePercent']/$DBnodes->count(), 2):0;
|
$counters['totalUsagePercent'] = ($DBnodes->count()) ? round($counters['totalUsagePercent'] / $DBnodes->count(), 2) : 0;
|
||||||
|
|
||||||
foreach(Pterodactyl::getServers() as $server){ //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total
|
foreach (Pterodactyl::getServers() as $server) { //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total
|
||||||
$nodeId = $server['attributes']['node'];
|
$nodeId = $server['attributes']['node'];
|
||||||
|
|
||||||
if($CPServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first()){
|
if ($CPServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first()) {
|
||||||
$price = Product::query()->where('id', $CPServer->product_id)->first()->price;
|
$price = Product::query()->where('id', $CPServer->product_id)->first()->price;
|
||||||
if (!$CPServer->suspended){
|
if (! $CPServer->suspended) {
|
||||||
$counters['earnings']->active += $price;
|
$counters['earnings']->active += $price;
|
||||||
$counters['servers']->active ++;
|
$counters['servers']->active++;
|
||||||
$nodes[$nodeId]->activeEarnings += $price;
|
$nodes[$nodeId]->activeEarnings += $price;
|
||||||
$nodes[$nodeId]->activeServers ++;
|
$nodes[$nodeId]->activeServers++;
|
||||||
}
|
}
|
||||||
$counters['earnings']->total += $price;
|
$counters['earnings']->total += $price;
|
||||||
$counters['servers']->total ++;
|
$counters['servers']->total++;
|
||||||
$nodes[$nodeId]->totalEarnings += $price;
|
$nodes[$nodeId]->totalEarnings += $price;
|
||||||
$nodes[$nodeId]->totalServers ++;
|
$nodes[$nodeId]->totalServers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Get latest tickets
|
//Get latest tickets
|
||||||
$tickets = collect();
|
$tickets = collect();
|
||||||
foreach(Ticket::query()->latest()->take(5)->get() as $ticket){
|
foreach (Ticket::query()->latest()->take(5)->get() as $ticket) {
|
||||||
$tickets->put($ticket->ticket_id, collect());
|
$tickets->put($ticket->ticket_id, collect());
|
||||||
$tickets[$ticket->ticket_id]->title = $ticket->title;
|
$tickets[$ticket->ticket_id]->title = $ticket->title;
|
||||||
$user = User::query()->where('id', $ticket->user_id)->first();
|
$user = User::query()->where('id', $ticket->user_id)->first();
|
||||||
|
@ -203,9 +204,9 @@ class OverViewController extends Controller
|
||||||
'counters' => $counters,
|
'counters' => $counters,
|
||||||
'nodes' => $nodes,
|
'nodes' => $nodes,
|
||||||
'syncLastUpdate' => $syncLastUpdate,
|
'syncLastUpdate' => $syncLastUpdate,
|
||||||
'deletedNodesPresent'=> ($DBnodes->count() != count($pteroNodeIds))?true:false,
|
'deletedNodesPresent' => ($DBnodes->count() != count($pteroNodeIds)) ? true : false,
|
||||||
'perPageLimit' => ($counters['servers']->total != Server::query()->count())?true:false,
|
'perPageLimit' => ($counters['servers']->total != Server::query()->count()) ? true : false,
|
||||||
'tickets' => $tickets
|
'tickets' => $tickets,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,13 @@ namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\InvoiceSettings;
|
|
||||||
use App\Models\PartnerDiscount;
|
use App\Models\PartnerDiscount;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\ShopProduct;
|
|
||||||
use App\Models\Settings;
|
use App\Models\Settings;
|
||||||
|
use App\Models\ShopProduct;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\InvoiceNotification;
|
|
||||||
use App\Notifications\ConfirmPaymentNotification;
|
use App\Notifications\ConfirmPaymentNotification;
|
||||||
|
use App\Notifications\InvoiceNotification;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -36,17 +35,15 @@ use PayPalHttp\HttpException;
|
||||||
use Stripe\Stripe;
|
use Stripe\Stripe;
|
||||||
use Symfony\Component\Intl\Currencies;
|
use Symfony\Component\Intl\Currencies;
|
||||||
|
|
||||||
|
|
||||||
class PaymentController extends Controller
|
class PaymentController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Application|Factory|View
|
* @return Application|Factory|View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
return view('admin.payments.index')->with([
|
return view('admin.payments.index')->with([
|
||||||
'payments' => Payment::paginate(15)
|
'payments' => Payment::paginate(15),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +57,11 @@ class PaymentController extends Controller
|
||||||
return view('store.checkout')->with([
|
return view('store.checkout')->with([
|
||||||
'product' => $shopProduct,
|
'product' => $shopProduct,
|
||||||
'discountpercent' => PartnerDiscount::getDiscount(),
|
'discountpercent' => PartnerDiscount::getDiscount(),
|
||||||
'discountvalue' => PartnerDiscount::getDiscount() * $shopProduct->price/100,
|
'discountvalue' => PartnerDiscount::getDiscount() * $shopProduct->price / 100,
|
||||||
'discountedprice' => $shopProduct->getPriceAfterDiscount(),
|
'discountedprice' => $shopProduct->getPriceAfterDiscount(),
|
||||||
'taxvalue' => $shopProduct->getTaxValue(),
|
'taxvalue' => $shopProduct->getTaxValue(),
|
||||||
'taxpercent' => $shopProduct->getTaxPercent(),
|
'taxpercent' => $shopProduct->getTaxPercent(),
|
||||||
'total' => $shopProduct->getTotalPrice()
|
'total' => $shopProduct->getTotalPrice(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,43 +128,40 @@ class PaymentController extends Controller
|
||||||
$request = new OrdersCreateRequest();
|
$request = new OrdersCreateRequest();
|
||||||
$request->prefer('return=representation');
|
$request->prefer('return=representation');
|
||||||
$request->body = [
|
$request->body = [
|
||||||
"intent" => "CAPTURE",
|
'intent' => 'CAPTURE',
|
||||||
"purchase_units" => [
|
'purchase_units' => [
|
||||||
[
|
[
|
||||||
"reference_id" => uniqid(),
|
'reference_id' => uniqid(),
|
||||||
"description" => $shopProduct->display . (PartnerDiscount::getDiscount()?(" (" . __('Discount') . " " . PartnerDiscount::getDiscount() . '%)'):""),
|
'description' => $shopProduct->display.(PartnerDiscount::getDiscount() ? (' ('.__('Discount').' '.PartnerDiscount::getDiscount().'%)') : ''),
|
||||||
"amount" => [
|
'amount' => [
|
||||||
"value" => $shopProduct->getTotalPrice(),
|
'value' => $shopProduct->getTotalPrice(),
|
||||||
'currency_code' => strtoupper($shopProduct->currency_code),
|
'currency_code' => strtoupper($shopProduct->currency_code),
|
||||||
'breakdown' => [
|
'breakdown' => [
|
||||||
'item_total' =>
|
'item_total' => [
|
||||||
[
|
|
||||||
'currency_code' => strtoupper($shopProduct->currency_code),
|
'currency_code' => strtoupper($shopProduct->currency_code),
|
||||||
'value' => $shopProduct->getPriceAfterDiscount(),
|
'value' => $shopProduct->getPriceAfterDiscount(),
|
||||||
],
|
],
|
||||||
'tax_total' =>
|
'tax_total' => [
|
||||||
[
|
|
||||||
'currency_code' => strtoupper($shopProduct->currency_code),
|
'currency_code' => strtoupper($shopProduct->currency_code),
|
||||||
'value' => $shopProduct->getTaxValue(),
|
'value' => $shopProduct->getTaxValue(),
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"application_context" => [
|
],
|
||||||
"cancel_url" => route('payment.Cancel'),
|
],
|
||||||
"return_url" => route('payment.PaypalSuccess', ['product' => $shopProduct->id]),
|
],
|
||||||
|
],
|
||||||
|
'application_context' => [
|
||||||
|
'cancel_url' => route('payment.Cancel'),
|
||||||
|
'return_url' => route('payment.PaypalSuccess', ['product' => $shopProduct->id]),
|
||||||
'brand_name' => config('app.name', 'Laravel'),
|
'brand_name' => config('app.name', 'Laravel'),
|
||||||
'shipping_preference' => 'NO_SHIPPING'
|
'shipping_preference' => 'NO_SHIPPING',
|
||||||
]
|
],
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Call API with your client and get a response for your call
|
// Call API with your client and get a response for your call
|
||||||
$response = $this->getPayPalClient()->execute($request);
|
$response = $this->getPayPalClient()->execute($request);
|
||||||
|
|
||||||
return redirect()->away($response->result->links[1]->href);
|
return redirect()->away($response->result->links[1]->href);
|
||||||
|
|
||||||
// If call returns body in response, you can get the deserialized version from the result attribute of the response
|
// If call returns body in response, you can get the deserialized version from the result attribute of the response
|
||||||
|
@ -194,7 +188,7 @@ class PaymentController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function getPaypalClientId()
|
protected function getPaypalClientId()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID") : config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID");
|
return env('APP_ENV') == 'local' ? config('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +196,7 @@ class PaymentController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function getPaypalClientSecret()
|
protected function getPaypalClientSecret()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : config("SETTINGS::PAYMENTS:PAYPAL:SECRET");
|
return env('APP_ENV') == 'local' ? config('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : config('SETTINGS::PAYMENTS:PAYPAL:SECRET');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,26 +225,25 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//update User with bought item
|
//update User with bought item
|
||||||
if ($shopProduct->type=="Credits") {
|
if ($shopProduct->type == 'Credits') {
|
||||||
$user->increment('credits', $shopProduct->quantity);
|
$user->increment('credits', $shopProduct->quantity);
|
||||||
}elseif ($shopProduct->type=="Server slots"){
|
} elseif ($shopProduct->type == 'Server slots') {
|
||||||
$user->increment('server_limit', $shopProduct->quantity);
|
$user->increment('server_limit', $shopProduct->quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//give referral commission always
|
//give referral commission always
|
||||||
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "true"){
|
if ((config('SETTINGS::REFERRAL:MODE') == 'commission' || config('SETTINGS::REFERRAL:MODE') == 'both') && $shopProduct->type == 'Credits' && config('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') == 'true') {
|
||||||
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
if ($ref_user = DB::table('user_referrals')->where('registered_user_id', '=', $user->id)->first()) {
|
||||||
$ref_user = User::findOrFail($ref_user->referral_id);
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
||||||
$increment = number_format($shopProduct->quantity*(PartnerDiscount::getCommission($ref_user->id))/100,0,"","");
|
$increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id)) / 100, 0, '', '');
|
||||||
$ref_user->increment('credits', $increment);
|
$ref_user->increment('credits', $increment);
|
||||||
|
|
||||||
//LOGS REFERRALS IN THE ACTIVITY LOG
|
//LOGS REFERRALS IN THE ACTIVITY LOG
|
||||||
activity()
|
activity()
|
||||||
->performedOn($user)
|
->performedOn($user)
|
||||||
->causedBy($ref_user)
|
->causedBy($ref_user)
|
||||||
->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
->log('gained '.$increment.' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update role give Referral-reward
|
//update role give Referral-reward
|
||||||
|
@ -258,21 +251,19 @@ class PaymentController extends Controller
|
||||||
$user->update(['role' => 'client']);
|
$user->update(['role' => 'client']);
|
||||||
|
|
||||||
//give referral commission only on first purchase
|
//give referral commission only on first purchase
|
||||||
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "false"){
|
if ((config('SETTINGS::REFERRAL:MODE') == 'commission' || config('SETTINGS::REFERRAL:MODE') == 'both') && $shopProduct->type == 'Credits' && config('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') == 'false') {
|
||||||
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
if ($ref_user = DB::table('user_referrals')->where('registered_user_id', '=', $user->id)->first()) {
|
||||||
$ref_user = User::findOrFail($ref_user->referral_id);
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
||||||
$increment = number_format($shopProduct->quantity*(PartnerDiscount::getCommission($ref_user->id))/100,0,"","");
|
$increment = number_format($shopProduct->quantity * (PartnerDiscount::getCommission($ref_user->id)) / 100, 0, '', '');
|
||||||
$ref_user->increment('credits', $increment);
|
$ref_user->increment('credits', $increment);
|
||||||
|
|
||||||
//LOGS REFERRALS IN THE ACTIVITY LOG
|
//LOGS REFERRALS IN THE ACTIVITY LOG
|
||||||
activity()
|
activity()
|
||||||
->performedOn($user)
|
->performedOn($user)
|
||||||
->causedBy($ref_user)
|
->causedBy($ref_user)
|
||||||
->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
->log('gained '.$increment.' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store payment
|
//store payment
|
||||||
|
@ -283,7 +274,7 @@ class PaymentController extends Controller
|
||||||
'type' => $shopProduct->type,
|
'type' => $shopProduct->type,
|
||||||
'status' => 'paid',
|
'status' => 'paid',
|
||||||
'amount' => $shopProduct->quantity,
|
'amount' => $shopProduct->quantity,
|
||||||
'price' => $shopProduct->price - ($shopProduct->price*PartnerDiscount::getDiscount()/100),
|
'price' => $shopProduct->price - ($shopProduct->price * PartnerDiscount::getDiscount() / 100),
|
||||||
'tax_value' => $shopProduct->getTaxValue(),
|
'tax_value' => $shopProduct->getTaxValue(),
|
||||||
'tax_percent' => $shopProduct->getTaxPercent(),
|
'tax_percent' => $shopProduct->getTaxPercent(),
|
||||||
'total_price' => $shopProduct->getTotalPrice(),
|
'total_price' => $shopProduct->getTotalPrice(),
|
||||||
|
@ -291,7 +282,6 @@ class PaymentController extends Controller
|
||||||
'shop_item_product_id' => $shopProduct->id,
|
'shop_item_product_id' => $shopProduct->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
||||||
|
@ -299,12 +289,10 @@ class PaymentController extends Controller
|
||||||
$this->createInvoice($user, $payment, 'paid', $shopProduct->currency_code);
|
$this->createInvoice($user, $payment, 'paid', $shopProduct->currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If call returns body in response, you can get the deserialized version from the result attribute of the response
|
// If call returns body in response, you can get the deserialized version from the result attribute of the response
|
||||||
if (env('APP_ENV') == 'local') {
|
if (env('APP_ENV') == 'local') {
|
||||||
dd($response);
|
dd($response);
|
||||||
|
@ -321,7 +309,6 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
|
@ -340,14 +327,13 @@ class PaymentController extends Controller
|
||||||
if(!$this->checkAmount($shopProduct->getTotalPrice(), strtoupper($shopProduct->currency_code), "stripe")) return redirect()->route('home')->with('error', __('The product you chose can´t be purchased with this payment method. The total amount is too small. Please buy a bigger amount or try a different payment method.'));
|
if(!$this->checkAmount($shopProduct->getTotalPrice(), strtoupper($shopProduct->currency_code), "stripe")) return redirect()->route('home')->with('error', __('The product you chose can´t be purchased with this payment method. The total amount is too small. Please buy a bigger amount or try a different payment method.'));
|
||||||
$stripeClient = $this->getStripeClient();
|
$stripeClient = $this->getStripeClient();
|
||||||
|
|
||||||
|
|
||||||
$request = $stripeClient->checkout->sessions->create([
|
$request = $stripeClient->checkout->sessions->create([
|
||||||
'line_items' => [
|
'line_items' => [
|
||||||
[
|
[
|
||||||
'price_data' => [
|
'price_data' => [
|
||||||
'currency' => $shopProduct->currency_code,
|
'currency' => $shopProduct->currency_code,
|
||||||
'product_data' => [
|
'product_data' => [
|
||||||
'name' => $shopProduct->display . (PartnerDiscount::getDiscount()?(" (" . __('Discount') . " " . PartnerDiscount::getDiscount() . '%)'):""),
|
'name' => $shopProduct->display.(PartnerDiscount::getDiscount() ? (' ('.__('Discount').' '.PartnerDiscount::getDiscount().'%)') : ''),
|
||||||
'description' => $shopProduct->description,
|
'description' => $shopProduct->description,
|
||||||
],
|
],
|
||||||
'unit_amount_decimal' => round($shopProduct->getPriceAfterDiscount() * 100, 2),
|
'unit_amount_decimal' => round($shopProduct->getPriceAfterDiscount() * 100, 2),
|
||||||
|
@ -359,22 +345,20 @@ class PaymentController extends Controller
|
||||||
'currency' => $shopProduct->currency_code,
|
'currency' => $shopProduct->currency_code,
|
||||||
'product_data' => [
|
'product_data' => [
|
||||||
'name' => __('Tax'),
|
'name' => __('Tax'),
|
||||||
'description' => $shopProduct->getTaxPercent() . "%",
|
'description' => $shopProduct->getTaxPercent().'%',
|
||||||
],
|
],
|
||||||
'unit_amount_decimal' => round($shopProduct->getTaxValue(), 2) * 100,
|
'unit_amount_decimal' => round($shopProduct->getTaxValue(), 2) * 100,
|
||||||
],
|
],
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'mode' => 'payment',
|
'mode' => 'payment',
|
||||||
"payment_method_types" => str_getcsv(config("SETTINGS::PAYMENTS:STRIPE:METHODS")),
|
'payment_method_types' => str_getcsv(config('SETTINGS::PAYMENTS:STRIPE:METHODS')),
|
||||||
'success_url' => route('payment.StripeSuccess', ['product' => $shopProduct->id]) . '&session_id={CHECKOUT_SESSION_ID}',
|
'success_url' => route('payment.StripeSuccess', ['product' => $shopProduct->id]).'&session_id={CHECKOUT_SESSION_ID}',
|
||||||
'cancel_url' => route('payment.Cancel'),
|
'cancel_url' => route('payment.Cancel'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return redirect($request->url, 303);
|
return redirect($request->url, 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,9 +384,7 @@ class PaymentController extends Controller
|
||||||
$paymentDbEntry = Payment::where('payment_id', $paymentSession->payment_intent)->count();
|
$paymentDbEntry = Payment::where('payment_id', $paymentSession->payment_intent)->count();
|
||||||
|
|
||||||
// check if payment is 100% completed and payment does not exist in db already
|
// check if payment is 100% completed and payment does not exist in db already
|
||||||
if ($paymentSession->status == "complete" && $paymentIntent->status == "succeeded" && $paymentDbEntry == 0) {
|
if ($paymentSession->status == 'complete' && $paymentIntent->status == 'succeeded' && $paymentDbEntry == 0) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
||||||
|
@ -412,9 +394,9 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//update User with bought item
|
//update User with bought item
|
||||||
if ($shopProduct->type=="Credits") {
|
if ($shopProduct->type == 'Credits') {
|
||||||
$user->increment('credits', $shopProduct->quantity);
|
$user->increment('credits', $shopProduct->quantity);
|
||||||
}elseif ($shopProduct->type=="Server slots"){
|
} elseif ($shopProduct->type == 'Server slots') {
|
||||||
$user->increment('server_limit', $shopProduct->quantity);
|
$user->increment('server_limit', $shopProduct->quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,21 +404,19 @@ class PaymentController extends Controller
|
||||||
if ($user->role == 'member') {
|
if ($user->role == 'member') {
|
||||||
$user->update(['role' => 'client']);
|
$user->update(['role' => 'client']);
|
||||||
|
|
||||||
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits"){
|
if ((config('SETTINGS::REFERRAL:MODE') == 'commission' || config('SETTINGS::REFERRAL:MODE') == 'both') && $shopProduct->type == 'Credits') {
|
||||||
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
if ($ref_user = DB::table('user_referrals')->where('registered_user_id', '=', $user->id)->first()) {
|
||||||
$ref_user = User::findOrFail($ref_user->referral_id);
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
||||||
$increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"","");
|
$increment = number_format($shopProduct->quantity / 100 * config('SETTINGS::REFERRAL:PERCENTAGE'), 0, '', '');
|
||||||
$ref_user->increment('credits', $increment);
|
$ref_user->increment('credits', $increment);
|
||||||
|
|
||||||
//LOGS REFERRALS IN THE ACTIVITY LOG
|
//LOGS REFERRALS IN THE ACTIVITY LOG
|
||||||
activity()
|
activity()
|
||||||
->performedOn($user)
|
->performedOn($user)
|
||||||
->causedBy($ref_user)
|
->causedBy($ref_user)
|
||||||
->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
->log('gained '.$increment.' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store paid payment
|
//store paid payment
|
||||||
|
@ -447,7 +427,7 @@ class PaymentController extends Controller
|
||||||
'type' => $shopProduct->type,
|
'type' => $shopProduct->type,
|
||||||
'status' => 'paid',
|
'status' => 'paid',
|
||||||
'amount' => $shopProduct->quantity,
|
'amount' => $shopProduct->quantity,
|
||||||
'price' => $shopProduct->price - ($shopProduct->price*PartnerDiscount::getDiscount()/100),
|
'price' => $shopProduct->price - ($shopProduct->price * PartnerDiscount::getDiscount() / 100),
|
||||||
'tax_value' => $shopProduct->getTaxValue(),
|
'tax_value' => $shopProduct->getTaxValue(),
|
||||||
'total_price' => $shopProduct->getTotalPrice(),
|
'total_price' => $shopProduct->getTotalPrice(),
|
||||||
'tax_percent' => $shopProduct->getTaxPercent(),
|
'tax_percent' => $shopProduct->getTaxPercent(),
|
||||||
|
@ -468,7 +448,7 @@ class PaymentController extends Controller
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
return redirect()->route('home')->with('success', __('Your credit balance has been increased!'));
|
||||||
} else {
|
} else {
|
||||||
if ($paymentIntent->status == "processing") {
|
if ($paymentIntent->status == 'processing') {
|
||||||
|
|
||||||
//store processing payment
|
//store processing payment
|
||||||
$payment = Payment::create([
|
$payment = Payment::create([
|
||||||
|
@ -494,7 +474,7 @@ class PaymentController extends Controller
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', __('Your payment is being processed!'));
|
return redirect()->route('home')->with('success', __('Your payment is being processed!'));
|
||||||
}
|
}
|
||||||
if ($paymentDbEntry == 0 && $paymentIntent->status != "processing") {
|
if ($paymentDbEntry == 0 && $paymentIntent->status != 'processing') {
|
||||||
$stripeClient->paymentIntents->cancel($paymentIntent->id);
|
$stripeClient->paymentIntents->cancel($paymentIntent->id);
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
|
@ -525,7 +505,6 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
if ($paymentIntent->status == 'succeeded' && $payment->status == 'processing') {
|
if ($paymentIntent->status == 'succeeded' && $payment->status == 'processing') {
|
||||||
|
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
||||||
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
||||||
|
@ -533,9 +512,9 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//update User with bought item
|
//update User with bought item
|
||||||
if ($shopProduct->type=="Credits") {
|
if ($shopProduct->type == 'Credits') {
|
||||||
$user->increment('credits', $shopProduct->quantity);
|
$user->increment('credits', $shopProduct->quantity);
|
||||||
}elseif ($shopProduct->type=="Server slots"){
|
} elseif ($shopProduct->type == 'Server slots') {
|
||||||
$user->increment('server_limit', $shopProduct->quantity);
|
$user->increment('server_limit', $shopProduct->quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,21 +522,19 @@ class PaymentController extends Controller
|
||||||
if ($user->role == 'member') {
|
if ($user->role == 'member') {
|
||||||
$user->update(['role' => 'client']);
|
$user->update(['role' => 'client']);
|
||||||
|
|
||||||
if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both")&& $shopProduct->type=="Credits"){
|
if ((config('SETTINGS::REFERRAL:MODE') == 'commission' || config('SETTINGS::REFERRAL:MODE') == 'both') && $shopProduct->type == 'Credits') {
|
||||||
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
if ($ref_user = DB::table('user_referrals')->where('registered_user_id', '=', $user->id)->first()) {
|
||||||
$ref_user = User::findOrFail($ref_user->referral_id);
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
||||||
$increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"","");
|
$increment = number_format($shopProduct->quantity / 100 * config('SETTINGS::REFERRAL:PERCENTAGE'), 0, '', '');
|
||||||
$ref_user->increment('credits', $increment);
|
$ref_user->increment('credits', $increment);
|
||||||
|
|
||||||
//LOGS REFERRALS IN THE ACTIVITY LOG
|
//LOGS REFERRALS IN THE ACTIVITY LOG
|
||||||
activity()
|
activity()
|
||||||
->performedOn($user)
|
->performedOn($user)
|
||||||
->causedBy($ref_user)
|
->causedBy($ref_user)
|
||||||
->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
->log('gained '.$increment.' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update payment db entry status
|
//update payment db entry status
|
||||||
|
@ -610,7 +587,7 @@ class PaymentController extends Controller
|
||||||
$this->handleStripePaymentSuccessHook($paymentIntent);
|
$this->handleStripePaymentSuccessHook($paymentIntent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo 'Received unknown event type ' . $event->type;
|
echo 'Received unknown event type '.$event->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,8 +605,8 @@ class PaymentController extends Controller
|
||||||
protected function getStripeSecret()
|
protected function getStripeSecret()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local'
|
return env('APP_ENV') == 'local'
|
||||||
? config("SETTINGS::PAYMENTS:STRIPE:TEST_SECRET")
|
? config('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET')
|
||||||
: config("SETTINGS::PAYMENTS:STRIPE:SECRET");
|
: config('SETTINGS::PAYMENTS:STRIPE:SECRET');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -638,31 +615,29 @@ class PaymentController extends Controller
|
||||||
protected function getStripeEndpointSecret()
|
protected function getStripeEndpointSecret()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local'
|
return env('APP_ENV') == 'local'
|
||||||
? config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET")
|
? config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET')
|
||||||
: config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET");
|
: config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function createInvoice($user, $payment, $paymentStatus, $currencyCode)
|
protected function createInvoice($user, $payment, $paymentStatus, $currencyCode)
|
||||||
{
|
{
|
||||||
$shopProduct = ShopProduct::where('id', $payment->shop_item_product_id)->first();
|
$shopProduct = ShopProduct::where('id', $payment->shop_item_product_id)->first();
|
||||||
//create invoice
|
//create invoice
|
||||||
$lastInvoiceID = \App\Models\Invoice::where("invoice_name", "like", "%" . now()->format('mY') . "%")->count("id");
|
$lastInvoiceID = \App\Models\Invoice::where('invoice_name', 'like', '%'.now()->format('mY').'%')->count('id');
|
||||||
$newInvoiceID = $lastInvoiceID + 1;
|
$newInvoiceID = $lastInvoiceID + 1;
|
||||||
$logoPath = storage_path('app/public/logo.png');
|
$logoPath = storage_path('app/public/logo.png');
|
||||||
|
|
||||||
$seller = new Party([
|
$seller = new Party([
|
||||||
'name' => config("SETTINGS::INVOICE:COMPANY_NAME"),
|
'name' => config('SETTINGS::INVOICE:COMPANY_NAME'),
|
||||||
'phone' => config("SETTINGS::INVOICE:COMPANY_PHONE"),
|
'phone' => config('SETTINGS::INVOICE:COMPANY_PHONE'),
|
||||||
'address' => config("SETTINGS::INVOICE:COMPANY_ADDRESS"),
|
'address' => config('SETTINGS::INVOICE:COMPANY_ADDRESS'),
|
||||||
'vat' => config("SETTINGS::INVOICE:COMPANY_VAT"),
|
'vat' => config('SETTINGS::INVOICE:COMPANY_VAT'),
|
||||||
'custom_fields' => [
|
'custom_fields' => [
|
||||||
'E-Mail' => config("SETTINGS::INVOICE:COMPANY_MAIL"),
|
'E-Mail' => config('SETTINGS::INVOICE:COMPANY_MAIL'),
|
||||||
"Web" => config("SETTINGS::INVOICE:COMPANY_WEBSITE")
|
'Web' => config('SETTINGS::INVOICE:COMPANY_WEBSITE'),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$customer = new Buyer([
|
$customer = new Buyer([
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
'custom_fields' => [
|
'custom_fields' => [
|
||||||
|
@ -675,14 +650,13 @@ class PaymentController extends Controller
|
||||||
->pricePerUnit($shopProduct->price);
|
->pricePerUnit($shopProduct->price);
|
||||||
|
|
||||||
$notes = [
|
$notes = [
|
||||||
__("Payment method") . ": " . $payment->payment_method,
|
__('Payment method').': '.$payment->payment_method,
|
||||||
];
|
];
|
||||||
$notes = implode("<br>", $notes);
|
$notes = implode('<br>', $notes);
|
||||||
|
|
||||||
|
|
||||||
$invoice = Invoice::make()
|
$invoice = Invoice::make()
|
||||||
->template('controlpanel')
|
->template('controlpanel')
|
||||||
->name(__("Invoice"))
|
->name(__('Invoice'))
|
||||||
->buyer($customer)
|
->buyer($customer)
|
||||||
->seller($seller)
|
->seller($seller)
|
||||||
->discountByPercent(PartnerDiscount::getDiscount())
|
->discountByPercent(PartnerDiscount::getDiscount())
|
||||||
|
@ -691,9 +665,9 @@ class PaymentController extends Controller
|
||||||
->addItem($item)
|
->addItem($item)
|
||||||
->status(__($paymentStatus))
|
->status(__($paymentStatus))
|
||||||
->series(now()->format('mY'))
|
->series(now()->format('mY'))
|
||||||
->delimiter("-")
|
->delimiter('-')
|
||||||
->sequence($newInvoiceID)
|
->sequence($newInvoiceID)
|
||||||
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
|
->serialNumberFormat(config('SETTINGS::INVOICE:PREFIX').'{DELIMITER}{SERIES}{SEQUENCE}')
|
||||||
->currencyCode($currencyCode)
|
->currencyCode($currencyCode)
|
||||||
->currencySymbol(Currencies::getSymbol($currencyCode))
|
->currencySymbol(Currencies::getSymbol($currencyCode))
|
||||||
->notes($notes);
|
->notes($notes);
|
||||||
|
@ -703,10 +677,9 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save the invoice in "storage\app\invoice\USER_ID\YEAR"
|
//Save the invoice in "storage\app\invoice\USER_ID\YEAR"
|
||||||
$invoice->filename = $invoice->getSerialNumber() . '.pdf';
|
$invoice->filename = $invoice->getSerialNumber().'.pdf';
|
||||||
$invoice->render();
|
$invoice->render();
|
||||||
Storage::disk("local")->put("invoice/" . $user->id . "/" . now()->format('Y') . "/" . $invoice->filename, $invoice->output);
|
Storage::disk('local')->put('invoice/'.$user->id.'/'.now()->format('Y').'/'.$invoice->filename, $invoice->output);
|
||||||
|
|
||||||
|
|
||||||
\App\Models\Invoice::create([
|
\App\Models\Invoice::create([
|
||||||
'invoice_user' => $user->id,
|
'invoice_user' => $user->id,
|
||||||
|
@ -828,6 +801,7 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return JsonResponse|mixed
|
* @return JsonResponse|mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
|
@ -835,9 +809,11 @@ class PaymentController extends Controller
|
||||||
$query = Payment::with('user');
|
$query = Payment::with('user');
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
|
|
||||||
->addColumn('user', function (Payment $payment) {
|
->addColumn('user', function (Payment $payment) {
|
||||||
return
|
return
|
||||||
($payment->user)?'<a href="'.route('admin.users.show', $payment->user->id).'">'.$payment->user->name.'</a>':__('Unknown user');
|
($payment->user)?'<a href="'.route('admin.users.show', $payment->user->id).'">'.$payment->user->name.'</a>':__('Unknown user');
|
||||||
|
|
||||||
})
|
})
|
||||||
->editColumn('price', function (Payment $payment) {
|
->editColumn('price', function (Payment $payment) {
|
||||||
return $payment->formatToCurrency($payment->price);
|
return $payment->formatToCurrency($payment->price);
|
||||||
|
@ -846,7 +822,7 @@ class PaymentController extends Controller
|
||||||
return $payment->formatToCurrency($payment->tax_value);
|
return $payment->formatToCurrency($payment->tax_value);
|
||||||
})
|
})
|
||||||
->editColumn('tax_percent', function (Payment $payment) {
|
->editColumn('tax_percent', function (Payment $payment) {
|
||||||
return $payment->tax_percent . ' %';
|
return $payment->tax_percent.' %';
|
||||||
})
|
})
|
||||||
->editColumn('total_price', function (Payment $payment) {
|
->editColumn('total_price', function (Payment $payment) {
|
||||||
return $payment->formatToCurrency($payment->total_price);
|
return $payment->formatToCurrency($payment->total_price);
|
||||||
|
@ -857,7 +833,7 @@ class PaymentController extends Controller
|
||||||
'raw' => $payment->created_at ? strtotime($payment->created_at) : ''];
|
'raw' => $payment->created_at ? strtotime($payment->created_at) : ''];
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (Payment $payment) {
|
->addColumn('actions', function (Payment $payment) {
|
||||||
return '<a data-content="' . __("Download") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.invoices.downloadSingleInvoice', "id=" . $payment->payment_id) . '" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-file-download"></i></a>';
|
return '<a data-content="'.__('Download').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.invoices.downloadSingleInvoice', 'id='.$payment->payment_id).'" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-file-download"></i></a>';
|
||||||
})
|
})
|
||||||
->rawColumns(['actions', 'user'])
|
->rawColumns(['actions', 'user'])
|
||||||
->make(true);
|
->make(true);
|
||||||
|
|
|
@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Nest;
|
use App\Models\Nest;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Settings;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -58,27 +57,27 @@ class ProductController extends Controller
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"name" => "required|max:30",
|
'name' => 'required|max:30',
|
||||||
"price" => "required|numeric|max:1000000|min:0",
|
'price' => 'required|numeric|max:1000000|min:0',
|
||||||
"memory" => "required|numeric|max:1000000|min:5",
|
'memory' => 'required|numeric|max:1000000|min:5',
|
||||||
"cpu" => "required|numeric|max:1000000|min:0",
|
'cpu' => 'required|numeric|max:1000000|min:0',
|
||||||
"swap" => "required|numeric|max:1000000|min:0",
|
'swap' => 'required|numeric|max:1000000|min:0',
|
||||||
"description" => "required|string|max:191",
|
'description' => 'required|string|max:191',
|
||||||
"disk" => "required|numeric|max:1000000|min:5",
|
'disk' => 'required|numeric|max:1000000|min:5',
|
||||||
"minimum_credits" => "required|numeric|max:1000000|min:-1",
|
'minimum_credits' => 'required|numeric|max:1000000|min:-1',
|
||||||
"io" => "required|numeric|max:1000000|min:0",
|
'io' => 'required|numeric|max:1000000|min:0',
|
||||||
"databases" => "required|numeric|max:1000000|min:0",
|
'databases' => 'required|numeric|max:1000000|min:0',
|
||||||
"backups" => "required|numeric|max:1000000|min:0",
|
'backups' => 'required|numeric|max:1000000|min:0',
|
||||||
"allocations" => "required|numeric|max:1000000|min:0",
|
'allocations' => 'required|numeric|max:1000000|min:0',
|
||||||
"nodes.*" => "required|exists:nodes,id",
|
'nodes.*' => 'required|exists:nodes,id',
|
||||||
"eggs.*" => "required|exists:eggs,id",
|
'eggs.*' => 'required|exists:eggs,id',
|
||||||
"disabled" => "nullable",
|
'disabled' => 'nullable',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disabled = !is_null($request->input('disabled'));
|
$disabled = ! is_null($request->input('disabled'));
|
||||||
$product = Product::create(array_merge($request->all(), ['disabled' => $disabled]));
|
$product = Product::create(array_merge($request->all(), ['disabled' => $disabled]));
|
||||||
|
|
||||||
#link nodes and eggs
|
//link nodes and eggs
|
||||||
$product->eggs()->attach($request->input('eggs'));
|
$product->eggs()->attach($request->input('eggs'));
|
||||||
$product->nodes()->attach($request->input('nodes'));
|
$product->nodes()->attach($request->input('nodes'));
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ class ProductController extends Controller
|
||||||
{
|
{
|
||||||
return view('admin.products.show', [
|
return view('admin.products.show', [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'minimum_credits' => config("SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"),
|
'minimum_credits' => config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,27 +123,27 @@ class ProductController extends Controller
|
||||||
public function update(Request $request, Product $product): RedirectResponse
|
public function update(Request $request, Product $product): RedirectResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"name" => "required|max:30",
|
'name' => 'required|max:30',
|
||||||
"price" => "required|numeric|max:1000000|min:0",
|
'price' => 'required|numeric|max:1000000|min:0',
|
||||||
"memory" => "required|numeric|max:1000000|min:5",
|
'memory' => 'required|numeric|max:1000000|min:5',
|
||||||
"cpu" => "required|numeric|max:1000000|min:0",
|
'cpu' => 'required|numeric|max:1000000|min:0',
|
||||||
"swap" => "required|numeric|max:1000000|min:0",
|
'swap' => 'required|numeric|max:1000000|min:0',
|
||||||
"description" => "required|string|max:191",
|
'description' => 'required|string|max:191',
|
||||||
"disk" => "required|numeric|max:1000000|min:5",
|
'disk' => 'required|numeric|max:1000000|min:5',
|
||||||
"io" => "required|numeric|max:1000000|min:0",
|
'io' => 'required|numeric|max:1000000|min:0',
|
||||||
"minimum_credits" => "required|numeric|max:1000000|min:-1",
|
'minimum_credits' => 'required|numeric|max:1000000|min:-1',
|
||||||
"databases" => "required|numeric|max:1000000|min:0",
|
'databases' => 'required|numeric|max:1000000|min:0',
|
||||||
"backups" => "required|numeric|max:1000000|min:0",
|
'backups' => 'required|numeric|max:1000000|min:0',
|
||||||
"allocations" => "required|numeric|max:1000000|min:0",
|
'allocations' => 'required|numeric|max:1000000|min:0',
|
||||||
"nodes.*" => "required|exists:nodes,id",
|
'nodes.*' => 'required|exists:nodes,id',
|
||||||
"eggs.*" => "required|exists:eggs,id",
|
'eggs.*' => 'required|exists:eggs,id',
|
||||||
"disabled" => "nullable",
|
'disabled' => 'nullable',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disabled = !is_null($request->input('disabled'));
|
$disabled = ! is_null($request->input('disabled'));
|
||||||
$product->update(array_merge($request->all(), ['disabled' => $disabled]));
|
$product->update(array_merge($request->all(), ['disabled' => $disabled]));
|
||||||
|
|
||||||
#link nodes and eggs
|
//link nodes and eggs
|
||||||
$product->eggs()->detach();
|
$product->eggs()->detach();
|
||||||
$product->nodes()->detach();
|
$product->nodes()->detach();
|
||||||
$product->eggs()->attach($request->input('eggs'));
|
$product->eggs()->attach($request->input('eggs'));
|
||||||
|
@ -160,7 +159,7 @@ class ProductController extends Controller
|
||||||
*/
|
*/
|
||||||
public function disable(Request $request, Product $product)
|
public function disable(Request $request, Product $product)
|
||||||
{
|
{
|
||||||
$product->update(['disabled' => !$product->disabled]);
|
$product->update(['disabled' => ! $product->disabled]);
|
||||||
|
|
||||||
return redirect()->route('admin.products.index')->with('success', 'Product has been updated!');
|
return redirect()->route('admin.products.index')->with('success', 'Product has been updated!');
|
||||||
}
|
}
|
||||||
|
@ -179,12 +178,13 @@ class ProductController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$product->delete();
|
$product->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Product has been removed!'));
|
return redirect()->back()->with('success', __('Product has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return JsonResponse|mixed
|
* @return JsonResponse|mixed
|
||||||
|
*
|
||||||
* @throws Exception|Exception
|
* @throws Exception|Exception
|
||||||
*/
|
*/
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
|
@ -194,14 +194,14 @@ class ProductController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (Product $product) {
|
->addColumn('actions', function (Product $product) {
|
||||||
return '
|
return '
|
||||||
<a data-content="' . __("Show") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.products.show', $product->id) . '" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
|
<a data-content="'.__('Show').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.products.show', $product->id).'" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
|
||||||
<a data-content="' . __("Clone") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.products.clone', $product->id) . '" class="btn btn-sm text-white btn-primary mr-1"><i class="fas fa-clone"></i></a>
|
<a data-content="'.__('Clone').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.products.clone', $product->id).'" class="btn btn-sm text-white btn-primary mr-1"><i class="fas fa-clone"></i></a>
|
||||||
<a data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.products.edit', $product->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.products.edit', $product->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
|
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.products.destroy', $product->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.products.destroy', $product->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="' . __("Delete") . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
|
@ -216,14 +216,15 @@ class ProductController extends Controller
|
||||||
return $product->eggs()->count();
|
return $product->eggs()->count();
|
||||||
})
|
})
|
||||||
->addColumn('disabled', function (Product $product) {
|
->addColumn('disabled', function (Product $product) {
|
||||||
$checked = $product->disabled == false ? "checked" : "";
|
$checked = $product->disabled == false ? 'checked' : '';
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.products.disable', $product->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.products.disable', $product->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("PATCH") . '
|
'.method_field('PATCH').'
|
||||||
<div class="custom-control custom-switch">
|
<div class="custom-control custom-switch">
|
||||||
<input ' . $checked . ' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch' . $product->id . '">
|
<input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$product->id.'">
|
||||||
<label class="custom-control-label" for="switch' . $product->id . '"></label>
|
<label class="custom-control-label" for="switch'.$product->id.'"></label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Classes\Pterodactyl;
|
use App\Classes\Pterodactyl;
|
||||||
use App\Classes\PterodactylWrapper;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Settings;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -66,11 +64,10 @@ class ServerController extends Controller
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function edit(Server $server)
|
public function edit(Server $server)
|
||||||
{
|
{
|
||||||
return view('admin.servers.edit')->with([
|
return view('admin.servers.edit')->with([
|
||||||
'server' => $server
|
'server' => $server,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +81,7 @@ class ServerController extends Controller
|
||||||
public function update(Request $request, Server $server)
|
public function update(Request $request, Server $server)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"identifier" => "required|string",
|
'identifier' => 'required|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->update($request->all());
|
$server->update($request->all());
|
||||||
|
@ -102,9 +99,10 @@ class ServerController extends Controller
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$server->delete();
|
$server->delete();
|
||||||
|
|
||||||
return redirect()->route('admin.servers.index')->with('success', __('Server removed'));
|
return redirect()->route('admin.servers.index')->with('success', __('Server removed'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return redirect()->route('admin.servers.index')->with('error', __('An exception has occurred while trying to remove a resource "') . $e->getMessage() . '"');
|
return redirect()->route('admin.servers.index')->with('error', __('An exception has occurred while trying to remove a resource "').$e->getMessage().'"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,20 +128,20 @@ class ServerController extends Controller
|
||||||
|
|
||||||
$CPIDArray = [];
|
$CPIDArray = [];
|
||||||
$renameCount = 0;
|
$renameCount = 0;
|
||||||
foreach($CPServers as $CPServer)//go thru all CP servers and make array with IDs as keys. All values are false.
|
foreach ($CPServers as $CPServer) {//go thru all CP servers and make array with IDs as keys. All values are false.
|
||||||
{
|
if ($CPServer->pterodactyl_id) {
|
||||||
if($CPServer->pterodactyl_id) $CPIDArray[$CPServer->pterodactyl_id] = false;
|
$CPIDArray[$CPServer->pterodactyl_id] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($pteroServers as $server)//go thru all ptero servers, if server exists, change value to true in array.
|
foreach ($pteroServers as $server) {//go thru all ptero servers, if server exists, change value to true in array.
|
||||||
{
|
if (isset($CPIDArray[$server['attributes']['id']])) {
|
||||||
if(isset($CPIDArray[$server['attributes']['id']])){
|
$CPIDArray[$server['attributes']['id']] = true;
|
||||||
$CPIDArray[$server['attributes']['id']]=true;
|
|
||||||
|
|
||||||
if(isset($server['attributes']['name'])){//failsafe
|
if (isset($server['attributes']['name'])) {//failsafe
|
||||||
//Check if a server got renamed
|
//Check if a server got renamed
|
||||||
$savedServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first();
|
$savedServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first();
|
||||||
if($savedServer->name != $server['attributes']['name']){
|
if ($savedServer->name != $server['attributes']['name']) {
|
||||||
$savedServer->name = $server['attributes']['name'];
|
$savedServer->name = $server['attributes']['name'];
|
||||||
$savedServer->save();
|
$savedServer->save();
|
||||||
$renameCount++;
|
$renameCount++;
|
||||||
|
@ -151,58 +149,66 @@ class ServerController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$filteredArray = array_filter($CPIDArray, function($v, $k) { return $v == false; }, ARRAY_FILTER_USE_BOTH); //Array of servers, that dont exist on ptero (value == false)
|
$filteredArray = array_filter($CPIDArray, function ($v, $k) {
|
||||||
|
return $v == false;
|
||||||
|
}, ARRAY_FILTER_USE_BOTH); //Array of servers, that dont exist on ptero (value == false)
|
||||||
$deleteCount = 0;
|
$deleteCount = 0;
|
||||||
foreach($filteredArray as $key => $CPID)//delete servers that dont exist on ptero anymore
|
foreach ($filteredArray as $key => $CPID) {//delete servers that dont exist on ptero anymore
|
||||||
{
|
if (! Pterodactyl::getServerAttributes($key, true)) {
|
||||||
if(!Pterodactyl::getServerAttributes($key, true)) $deleteCount++;
|
$deleteCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Servers synced successfully' . (($renameCount)?(',\n' . __('renamed') . ' ' . $renameCount . ' ' . __('servers')):'') . ((count($filteredArray))?(',\n' . __('deleted') . ' ' . $deleteCount . '/' . count($filteredArray) . ' ' . __('old servers')):''))) . '.';
|
return redirect()->back()->with('success', __('Servers synced successfully'.(($renameCount) ? (',\n'.__('renamed').' '.$renameCount.' '.__('servers')) : '').((count($filteredArray)) ? (',\n'.__('deleted').' '.$deleteCount.'/'.count($filteredArray).' '.__('old servers')) : ''))).'.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return JsonResponse|mixed
|
* @return JsonResponse|mixed
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dataTable(Request $request)
|
public function dataTable(Request $request)
|
||||||
{
|
{
|
||||||
$query = Server::with(['user', 'product']);
|
$query = Server::with(['user', 'product']);
|
||||||
if ($request->has('product')) $query->where('product_id', '=', $request->input('product'));
|
if ($request->has('product')) {
|
||||||
if ($request->has('user')) $query->where('user_id', '=', $request->input('user'));
|
$query->where('product_id', '=', $request->input('product'));
|
||||||
|
}
|
||||||
|
if ($request->has('user')) {
|
||||||
|
$query->where('user_id', '=', $request->input('user'));
|
||||||
|
}
|
||||||
$query->select('servers.*');
|
$query->select('servers.*');
|
||||||
|
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('user', function (Server $server) {
|
->addColumn('user', function (Server $server) {
|
||||||
return '<a href="' . route('admin.users.show', $server->user->id) . '">' . $server->user->name . '</a>';
|
return '<a href="'.route('admin.users.show', $server->user->id).'">'.$server->user->name.'</a>';
|
||||||
})
|
})
|
||||||
->addColumn('resources', function (Server $server) {
|
->addColumn('resources', function (Server $server) {
|
||||||
return $server->product->description;
|
return $server->product->description;
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (Server $server) {
|
->addColumn('actions', function (Server $server) {
|
||||||
$suspendColor = $server->isSuspended() ? "btn-success" : "btn-warning";
|
$suspendColor = $server->isSuspended() ? 'btn-success' : 'btn-warning';
|
||||||
$suspendIcon = $server->isSuspended() ? "fa-play-circle" : "fa-pause-circle";
|
$suspendIcon = $server->isSuspended() ? 'fa-play-circle' : 'fa-pause-circle';
|
||||||
$suspendText = $server->isSuspended() ? __("Unsuspend") : __("Suspend");
|
$suspendText = $server->isSuspended() ? __('Unsuspend') : __('Suspend');
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<a data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.servers.edit', $server->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.servers.edit', $server->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
<form class="d-inline" method="post" action="' . route('admin.servers.togglesuspend', $server->id) . '">
|
<form class="d-inline" method="post" action="'.route('admin.servers.togglesuspend', $server->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
<button data-content="' . $suspendText . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm ' . $suspendColor . ' text-white mr-1"><i class="far ' . $suspendIcon . '"></i></button>
|
<button data-content="'.$suspendText.'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm '.$suspendColor.' text-white mr-1"><i class="far '.$suspendIcon.'"></i></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.servers.destroy', $server->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.servers.destroy', $server->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="' . __("Delete") . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->addColumn('status', function (Server $server) {
|
->addColumn('status', function (Server $server) {
|
||||||
$labelColor = $server->isSuspended() ? 'text-danger' : 'text-success';
|
$labelColor = $server->isSuspended() ? 'text-danger' : 'text-success';
|
||||||
return '<i class="fas ' . $labelColor . ' fa-circle mr-2"></i>';
|
|
||||||
|
return '<i class="fas '.$labelColor.' fa-circle mr-2"></i>';
|
||||||
})
|
})
|
||||||
->editColumn('created_at', function (Server $server) {
|
->editColumn('created_at', function (Server $server) {
|
||||||
return $server->created_at ? $server->created_at->diffForHumans() : '';
|
return $server->created_at ? $server->created_at->diffForHumans() : '';
|
||||||
|
@ -211,7 +217,7 @@ class ServerController extends Controller
|
||||||
return $server->suspended ? $server->suspended->diffForHumans() : '';
|
return $server->suspended ? $server->suspended->diffForHumans() : '';
|
||||||
})
|
})
|
||||||
->editColumn('name', function (Server $server) {
|
->editColumn('name', function (Server $server) {
|
||||||
return '<a class="text-info" target="_blank" href="' . config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/servers/view/' . $server->pterodactyl_id . '">' . strip_tags($server->name) . '</a>';
|
return '<a class="text-info" target="_blank" href="'.config('SETTINGS::SYSTEM:PTERODACTYL:URL').'/admin/servers/view/'.$server->pterodactyl_id.'">'.strip_tags($server->name).'</a>';
|
||||||
})
|
})
|
||||||
->rawColumns(['user', 'actions', 'status', 'name'])
|
->rawColumns(['user', 'actions', 'status', 'name'])
|
||||||
->make();
|
->make();
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Settings;
|
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
class SettingsController extends Controller
|
class SettingsController extends Controller
|
||||||
|
@ -22,7 +20,7 @@ class SettingsController extends Controller
|
||||||
//Get all tabs as laravel view paths
|
//Get all tabs as laravel view paths
|
||||||
$tabs = [];
|
$tabs = [];
|
||||||
foreach (glob(resource_path('views/admin/settings/tabs/*.blade.php')) as $filename) {
|
foreach (glob(resource_path('views/admin/settings/tabs/*.blade.php')) as $filename) {
|
||||||
$tabs[] = 'admin.settings.tabs.' . basename($filename, '.blade.php');
|
$tabs[] = 'admin.settings.tabs.'.basename($filename, '.blade.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate a html list item for each tab based on tabs file basename, set first tab as active
|
//Generate a html list item for each tab based on tabs file basename, set first tab as active
|
||||||
|
@ -30,8 +28,8 @@ class SettingsController extends Controller
|
||||||
foreach ($tabs as $tab) {
|
foreach ($tabs as $tab) {
|
||||||
$tabName = str_replace('admin.settings.tabs.', '', $tab);
|
$tabName = str_replace('admin.settings.tabs.', '', $tab);
|
||||||
$tabListItems[] = '<li class="nav-item">
|
$tabListItems[] = '<li class="nav-item">
|
||||||
<a class="nav-link ' . (empty($tabListItems) ? 'active' : '') . '" data-toggle="pill" href="#' . $tabName . '">
|
<a class="nav-link '.(empty($tabListItems) ? 'active' : '').'" data-toggle="pill" href="#'.$tabName.'">
|
||||||
' . __(ucfirst($tabName)) . '
|
'.__(ucfirst($tabName)).'
|
||||||
</a></li>';
|
</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\ShopProduct;
|
use App\Models\ShopProduct;
|
||||||
use App\Models\Settings;
|
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
|
@ -26,12 +25,14 @@ class ShopProductController extends Controller
|
||||||
|
|
||||||
if (
|
if (
|
||||||
env('APP_ENV') == 'local' ||
|
env('APP_ENV') == 'local' ||
|
||||||
config("SETTINGS::PAYMENTS:PAYPAL:SECRET") && config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
|
config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
|
||||||
config("SETTINGS::PAYMENTS:STRIPE:SECRET") && config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && config("SETTINGS::PAYMENTS:STRIPE:METHODS")
|
config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
|
||||||
) $isPaymentSetup = true;
|
) {
|
||||||
|
$isPaymentSetup = true;
|
||||||
|
}
|
||||||
|
|
||||||
return view('admin.store.index', [
|
return view('admin.store.index', [
|
||||||
'isPaymentSetup' => $isPaymentSetup
|
'isPaymentSetup' => $isPaymentSetup,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ class ShopProductController extends Controller
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('admin.store.create', [
|
return view('admin.store.create', [
|
||||||
'currencyCodes' => config('currency_codes')
|
'currencyCodes' => config('currency_codes'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,16 +57,16 @@ class ShopProductController extends Controller
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"disabled" => "nullable",
|
'disabled' => 'nullable',
|
||||||
"type" => "required|string",
|
'type' => 'required|string',
|
||||||
"currency_code" => ["required", "string", "max:3", Rule::in(config('currency_codes'))],
|
'currency_code' => ['required', 'string', 'max:3', Rule::in(config('currency_codes'))],
|
||||||
"price" => "required|regex:/^\d+(\.\d{1,2})?$/",
|
'price' => "required|regex:/^\d+(\.\d{1,2})?$/",
|
||||||
"quantity" => "required|numeric",
|
'quantity' => 'required|numeric',
|
||||||
"description" => "required|string|max:60",
|
'description' => 'required|string|max:60',
|
||||||
"display" => "required|string|max:60",
|
'display' => 'required|string|max:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disabled = !is_null($request->input('disabled'));
|
$disabled = ! is_null($request->input('disabled'));
|
||||||
ShopProduct::create(array_merge($request->all(), ['disabled' => $disabled]));
|
ShopProduct::create(array_merge($request->all(), ['disabled' => $disabled]));
|
||||||
|
|
||||||
return redirect()->route('admin.store.index')->with('success', __('Store item has been created!'));
|
return redirect()->route('admin.store.index')->with('success', __('Store item has been created!'));
|
||||||
|
@ -92,7 +93,7 @@ class ShopProductController extends Controller
|
||||||
{
|
{
|
||||||
return view('admin.store.edit', [
|
return view('admin.store.edit', [
|
||||||
'currencyCodes' => config('currency_codes'),
|
'currencyCodes' => config('currency_codes'),
|
||||||
'shopProduct' => $shopProduct
|
'shopProduct' => $shopProduct,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,16 +107,16 @@ class ShopProductController extends Controller
|
||||||
public function update(Request $request, ShopProduct $shopProduct)
|
public function update(Request $request, ShopProduct $shopProduct)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"disabled" => "nullable",
|
'disabled' => 'nullable',
|
||||||
"type" => "required|string",
|
'type' => 'required|string',
|
||||||
"currency_code" => ["required", "string", "max:3", Rule::in(config('currency_codes'))],
|
'currency_code' => ['required', 'string', 'max:3', Rule::in(config('currency_codes'))],
|
||||||
"price" => "required|regex:/^\d+(\.\d{1,2})?$/",
|
'price' => "required|regex:/^\d+(\.\d{1,2})?$/",
|
||||||
"quantity" => "required|numeric|max:100000000",
|
'quantity' => 'required|numeric|max:100000000',
|
||||||
"description" => "required|string|max:60",
|
'description' => 'required|string|max:60',
|
||||||
"display" => "required|string|max:60",
|
'display' => 'required|string|max:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disabled = !is_null($request->input('disabled'));
|
$disabled = ! is_null($request->input('disabled'));
|
||||||
$shopProduct->update(array_merge($request->all(), ['disabled' => $disabled]));
|
$shopProduct->update(array_merge($request->all(), ['disabled' => $disabled]));
|
||||||
|
|
||||||
return redirect()->route('admin.store.index')->with('success', __('Store item has been updated!'));
|
return redirect()->route('admin.store.index')->with('success', __('Store item has been updated!'));
|
||||||
|
@ -128,7 +129,7 @@ class ShopProductController extends Controller
|
||||||
*/
|
*/
|
||||||
public function disable(Request $request, ShopProduct $shopProduct)
|
public function disable(Request $request, ShopProduct $shopProduct)
|
||||||
{
|
{
|
||||||
$shopProduct->update(['disabled' => !$shopProduct->disabled]);
|
$shopProduct->update(['disabled' => ! $shopProduct->disabled]);
|
||||||
|
|
||||||
return redirect()->route('admin.store.index')->with('success', __('Product has been updated!'));
|
return redirect()->route('admin.store.index')->with('success', __('Product has been updated!'));
|
||||||
}
|
}
|
||||||
|
@ -142,10 +143,10 @@ class ShopProductController extends Controller
|
||||||
public function destroy(ShopProduct $shopProduct)
|
public function destroy(ShopProduct $shopProduct)
|
||||||
{
|
{
|
||||||
$shopProduct->delete();
|
$shopProduct->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Store item has been removed!'));
|
return redirect()->back()->with('success', __('Store item has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
{
|
{
|
||||||
$query = ShopProduct::query();
|
$query = ShopProduct::query();
|
||||||
|
@ -153,24 +154,25 @@ class ShopProductController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (ShopProduct $shopProduct) {
|
->addColumn('actions', function (ShopProduct $shopProduct) {
|
||||||
return '
|
return '
|
||||||
<a data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.store.edit', $shopProduct->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.store.edit', $shopProduct->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
|
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.destroy', $shopProduct->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.store.destroy', $shopProduct->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="' . __("Delete") . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->addColumn('disabled', function (ShopProduct $shopProduct) {
|
->addColumn('disabled', function (ShopProduct $shopProduct) {
|
||||||
$checked = $shopProduct->disabled == false ? "checked" : "";
|
$checked = $shopProduct->disabled == false ? 'checked' : '';
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.disable', $shopProduct->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.store.disable', $shopProduct->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("PATCH") . '
|
'.method_field('PATCH').'
|
||||||
<div class="custom-control custom-switch">
|
<div class="custom-control custom-switch">
|
||||||
<input ' . $checked . ' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch' . $shopProduct->id . '">
|
<input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$shopProduct->id.'">
|
||||||
<label class="custom-control-label" for="switch' . $shopProduct->id . '"></label>
|
<label class="custom-control-label" for="switch'.$shopProduct->id.'"></label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
|
|
|
@ -41,7 +41,6 @@ class UsefulLinkController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'icon' => 'required|string',
|
'icon' => 'required|string',
|
||||||
'title' => 'required|string|max:60',
|
'title' => 'required|string|max:60',
|
||||||
|
@ -50,6 +49,7 @@ class UsefulLinkController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
UsefulLink::create($request->all());
|
UsefulLink::create($request->all());
|
||||||
|
|
||||||
return redirect()->route('admin.usefullinks.index')->with('success', __('link has been created!'));
|
return redirect()->route('admin.usefullinks.index')->with('success', __('link has been created!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ class UsefulLinkController extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit(UsefulLink $usefullink)
|
public function edit(UsefulLink $usefullink)
|
||||||
{
|
{
|
||||||
return view('admin.usefullinks.edit' , [
|
return view('admin.usefullinks.edit', [
|
||||||
'link' => $usefullink
|
'link' => $usefullink,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ class UsefulLinkController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$usefullink->update($request->all());
|
$usefullink->update($request->all());
|
||||||
|
|
||||||
return redirect()->route('admin.usefullinks.index')->with('success', __('link has been updated!'));
|
return redirect()->route('admin.usefullinks.index')->with('success', __('link has been updated!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ class UsefulLinkController extends Controller
|
||||||
public function destroy(UsefulLink $usefullink)
|
public function destroy(UsefulLink $usefullink)
|
||||||
{
|
{
|
||||||
$usefullink->delete();
|
$usefullink->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('product has been removed!'));
|
return redirect()->back()->with('success', __('product has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,12 +118,12 @@ class UsefulLinkController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (UsefulLink $link) {
|
->addColumn('actions', function (UsefulLink $link) {
|
||||||
return '
|
return '
|
||||||
<a data-content="'.__("Edit").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.usefullinks.edit', $link->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.usefullinks.edit', $link->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
|
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.usefullinks.destroy', $link->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.usefullinks.destroy', $link->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
|
@ -131,7 +133,7 @@ class UsefulLinkController extends Controller
|
||||||
->editColumn('icon', function (UsefulLink $link) {
|
->editColumn('icon', function (UsefulLink $link) {
|
||||||
return "<i class='{$link->icon}'></i>";
|
return "<i class='{$link->icon}'></i>";
|
||||||
})
|
})
|
||||||
->rawColumns(['actions' , 'icon'])
|
->rawColumns(['actions', 'icon'])
|
||||||
->make();
|
->make();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,8 @@ namespace App\Http\Controllers\Admin;
|
||||||
use App\Classes\Pterodactyl;
|
use App\Classes\Pterodactyl;
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\DynamicNotification;
|
use App\Notifications\DynamicNotification;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -19,11 +16,13 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -55,16 +54,16 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
//QUERY ALL REFERRALS A USER HAS
|
//QUERY ALL REFERRALS A USER HAS
|
||||||
//i am not proud of this at all.
|
//i am not proud of this at all.
|
||||||
$allReferals = array();
|
$allReferals = [];
|
||||||
$referrals = DB::table("user_referrals")->where("referral_id","=",$user->id)->get();
|
$referrals = DB::table('user_referrals')->where('referral_id', '=', $user->id)->get();
|
||||||
foreach($referrals as $referral){
|
foreach ($referrals as $referral) {
|
||||||
array_push($allReferals, $allReferals["id"] = User::query()->findOrFail($referral->registered_user_id));
|
array_push($allReferals, $allReferals['id'] = User::query()->findOrFail($referral->registered_user_id));
|
||||||
}
|
}
|
||||||
array_pop($allReferals);
|
array_pop($allReferals);
|
||||||
|
|
||||||
return view('admin.users.show')->with([
|
return view('admin.users.show')->with([
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'referrals' => $allReferals
|
'referrals' => $allReferals,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +91,7 @@ class UserController extends Controller
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
|
@ -101,7 +101,7 @@ class UserController extends Controller
|
||||||
public function edit(User $user)
|
public function edit(User $user)
|
||||||
{
|
{
|
||||||
return view('admin.users.edit')->with([
|
return view('admin.users.edit')->with([
|
||||||
'user' => $user
|
'user' => $user,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,31 +111,31 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, User $user)
|
public function update(Request $request, User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"name" => "required|string|min:4|max:30",
|
'name' => 'required|string|min:4|max:30',
|
||||||
"pterodactyl_id" => "required|numeric|unique:users,pterodactyl_id,{$user->id}",
|
'pterodactyl_id' => "required|numeric|unique:users,pterodactyl_id,{$user->id}",
|
||||||
"email" => "required|string|email",
|
'email' => 'required|string|email',
|
||||||
"credits" => "required|numeric|min:0|max:99999999",
|
'credits' => 'required|numeric|min:0|max:99999999',
|
||||||
"server_limit" => "required|numeric|min:0|max:1000000",
|
'server_limit' => 'required|numeric|min:0|max:1000000',
|
||||||
"role" => Rule::in(['admin', 'moderator', 'client', 'member']),
|
'role' => Rule::in(['admin', 'moderator', 'client', 'member']),
|
||||||
"referral_code" => "required|string|min:2|max:32|unique:users,referral_code,{$user->id}",
|
'referral_code' => "required|string|min:2|max:32|unique:users,referral_code,{$user->id}",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
|
if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")]
|
'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($request->input('new_password'))) {
|
if (! is_null($request->input('new_password'))) {
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'new_password' => 'required|string|min:8',
|
'new_password' => 'required|string|min:8',
|
||||||
'new_password_confirmation' => 'required|same:new_password'
|
'new_password_confirmation' => 'required|same:new_password',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
|
@ -158,8 +158,10 @@ class UserController extends Controller
|
||||||
public function destroy(User $user)
|
public function destroy(User $user)
|
||||||
{
|
{
|
||||||
$user->delete();
|
$user->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('user has been removed!'));
|
return redirect()->back()->with('success', __('user has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifys the users email
|
* Verifys the users email
|
||||||
*
|
*
|
||||||
|
@ -169,6 +171,7 @@ class UserController extends Controller
|
||||||
public function verifyEmail(Request $request, User $user)
|
public function verifyEmail(Request $request, User $user)
|
||||||
{
|
{
|
||||||
$user->verifyEmail();
|
$user->verifyEmail();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Email has been verified!'));
|
return redirect()->back()->with('success', __('Email has been verified!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +184,7 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
$request->session()->put('previousUser', Auth::user()->id);
|
$request->session()->put('previousUser', Auth::user()->id);
|
||||||
Auth::login($user);
|
Auth::login($user);
|
||||||
|
|
||||||
return redirect()->route('home');
|
return redirect()->route('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +196,7 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
Auth::loginUsingId($request->session()->get('previousUser'), true);
|
Auth::loginUsingId($request->session()->get('previousUser'), true);
|
||||||
$request->session()->remove('previousUser');
|
$request->session()->remove('previousUser');
|
||||||
|
|
||||||
return redirect()->route('admin.users.index');
|
return redirect()->route('admin.users.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,36 +217,38 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function notify(Request $request)
|
public function notify(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
"via" => "required|min:1|array",
|
'via' => 'required|min:1|array',
|
||||||
"via.*" => "required|string|in:mail,database",
|
'via.*' => 'required|string|in:mail,database',
|
||||||
"all" => "required_without:users|boolean",
|
'all' => 'required_without:users|boolean',
|
||||||
"users" => "required_without:all|min:1|array",
|
'users' => 'required_without:all|min:1|array',
|
||||||
"users.*" => "exists:users,id",
|
'users.*' => 'exists:users,id',
|
||||||
"title" => "required|string|min:1",
|
'title' => 'required|string|min:1',
|
||||||
"content" => "required|string|min:1"
|
'content' => 'required|string|min:1',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$mail = null;
|
$mail = null;
|
||||||
$database = null;
|
$database = null;
|
||||||
if (in_array('database', $data["via"])) {
|
if (in_array('database', $data['via'])) {
|
||||||
$database = [
|
$database = [
|
||||||
"title" => $data["title"],
|
'title' => $data['title'],
|
||||||
"content" => $data["content"]
|
'content' => $data['content'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (in_array('mail', $data["via"])) {
|
if (in_array('mail', $data['via'])) {
|
||||||
$mail = (new MailMessage)
|
$mail = (new MailMessage)
|
||||||
->subject($data["title"])
|
->subject($data['title'])
|
||||||
->line(new HtmlString($data["content"]));
|
->line(new HtmlString($data['content']));
|
||||||
}
|
}
|
||||||
$all = $data["all"] ?? false;
|
$all = $data['all'] ?? false;
|
||||||
$users = $all ? User::all() : User::whereIn("id", $data["users"])->get();
|
$users = $all ? User::all() : User::whereIn('id', $data['users'])->get();
|
||||||
Notification::send($users, new DynamicNotification($data["via"], $database, $mail));
|
Notification::send($users, new DynamicNotification($data['via'], $database, $mail));
|
||||||
|
|
||||||
return redirect()->route('admin.users.notifications')->with('success', __('Notification sent!'));
|
return redirect()->route('admin.users.notifications')->with('success', __('Notification sent!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +259,7 @@ class UserController extends Controller
|
||||||
public function toggleSuspended(User $user)
|
public function toggleSuspended(User $user)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
!$user->isSuspended() ? $user->suspend() : $user->unSuspend();
|
! $user->isSuspended() ? $user->suspend() : $user->unSuspend();
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
return redirect()->back()->with('error', $exception->getMessage());
|
return redirect()->back()->with('error', $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -261,7 +268,6 @@ class UserController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
|
@ -270,10 +276,10 @@ class UserController extends Controller
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('avatar', function (User $user) {
|
->addColumn('avatar', function (User $user) {
|
||||||
return '<img width="28px" height="28px" class="rounded-circle ml-1" src="' . $user->getAvatar() . '">';
|
return '<img width="28px" height="28px" class="rounded-circle ml-1" src="'.$user->getAvatar().'">';
|
||||||
})
|
})
|
||||||
->addColumn('credits', function (User $user) {
|
->addColumn('credits', function (User $user) {
|
||||||
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
|
return '<i class="fas fa-coins mr-2"></i> '.$user->credits();
|
||||||
})
|
})
|
||||||
->addColumn('verified', function (User $user) {
|
->addColumn('verified', function (User $user) {
|
||||||
return $user->getVerifiedStatus();
|
return $user->getVerifiedStatus();
|
||||||
|
@ -282,32 +288,33 @@ class UserController extends Controller
|
||||||
return $user->servers->count();
|
return $user->servers->count();
|
||||||
})
|
})
|
||||||
->addColumn('referrals', function (User $user) {
|
->addColumn('referrals', function (User $user) {
|
||||||
return DB::table('user_referrals')->where("referral_id","=",$user->id)->count();
|
return DB::table('user_referrals')->where('referral_id', '=', $user->id)->count();
|
||||||
})
|
})
|
||||||
->addColumn('discordId', function (User $user) {
|
->addColumn('discordId', function (User $user) {
|
||||||
return $user->discordUser ? $user->discordUser->id : '';
|
return $user->discordUser ? $user->discordUser->id : '';
|
||||||
})
|
})
|
||||||
->addColumn('last_seen', function (User $user) {
|
->addColumn('last_seen', function (User $user) {
|
||||||
return ['display' => $user->last_seen ? $user->last_seen->diffForHumans() : '',
|
return ['display' => $user->last_seen ? $user->last_seen->diffForHumans() : '',
|
||||||
'raw' => $user->last_seen ? strtotime($user->last_seen) : ''];
|
'raw' => $user->last_seen ? strtotime($user->last_seen) : '', ];
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (User $user) {
|
->addColumn('actions', function (User $user) {
|
||||||
$suspendColor = $user->isSuspended() ? "btn-success" : "btn-warning";
|
$suspendColor = $user->isSuspended() ? 'btn-success' : 'btn-warning';
|
||||||
$suspendIcon = $user->isSuspended() ? "fa-play-circle" : "fa-pause-circle";
|
$suspendIcon = $user->isSuspended() ? 'fa-play-circle' : 'fa-pause-circle';
|
||||||
$suspendText = $user->isSuspended() ? __("Unsuspend") : __("Suspend");
|
$suspendText = $user->isSuspended() ? __('Unsuspend') : __('Suspend');
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<a data-content="' . __("Login as User") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.loginas', $user->id) . '" class="btn btn-sm btn-primary mr-1"><i class="fas fa-sign-in-alt"></i></a>
|
<a data-content="'.__('Login as User').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.users.loginas', $user->id).'" class="btn btn-sm btn-primary mr-1"><i class="fas fa-sign-in-alt"></i></a>
|
||||||
<a data-content="' . __("Verify") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.verifyEmail', $user->id) . '" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-envelope"></i></a>
|
<a data-content="'.__('Verify').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.users.verifyEmail', $user->id).'" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-envelope"></i></a>
|
||||||
<a data-content="' . __("Show") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.show', $user->id) . '" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
|
<a data-content="'.__('Show').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.users.show', $user->id).'" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
|
||||||
<a data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.edit', $user->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.users.edit', $user->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
<form class="d-inline" method="post" action="' . route('admin.users.togglesuspend', $user->id) . '">
|
<form class="d-inline" method="post" action="'.route('admin.users.togglesuspend', $user->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
<button data-content="' . $suspendText . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm ' . $suspendColor . ' text-white mr-1"><i class="far ' . $suspendIcon . '"></i></button>
|
<button data-content="'.$suspendText.'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm '.$suspendColor.' text-white mr-1"><i class="far '.$suspendIcon.'"></i></button>
|
||||||
</form>
|
</form>
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.users.destroy', $user->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.users.destroy', $user->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="' . __("Delete") . '" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
|
@ -327,10 +334,10 @@ class UserController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="badge ' . $badgeColor . '">' . $user->role . '</span>';
|
return '<span class="badge '.$badgeColor.'">'.$user->role.'</span>';
|
||||||
})
|
})
|
||||||
->editColumn('name', function (User $user) {
|
->editColumn('name', function (User $user) {
|
||||||
return '<a class="text-info" target="_blank" href="' . config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/users/view/' . $user->pterodactyl_id . '">' . strip_tags($user->name) . '</a>';
|
return '<a class="text-info" target="_blank" href="'.config('SETTINGS::SYSTEM:PTERODACTYL:URL').'/admin/users/view/'.$user->pterodactyl_id.'">'.strip_tags($user->name).'</a>';
|
||||||
})
|
})
|
||||||
/*->orderColumn('last_seen', function ($query) {
|
/*->orderColumn('last_seen', function ($query) {
|
||||||
$query->orderBy('last_seen', "desc");
|
$query->orderBy('last_seen', "desc");
|
||||||
|
|
|
@ -78,7 +78,7 @@ class VoucherController extends Controller
|
||||||
public function edit(Voucher $voucher)
|
public function edit(Voucher $voucher)
|
||||||
{
|
{
|
||||||
return view('admin.vouchers.edit', [
|
return view('admin.vouchers.edit', [
|
||||||
'voucher' => $voucher
|
'voucher' => $voucher,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,55 +113,65 @@ class VoucherController extends Controller
|
||||||
public function destroy(Voucher $voucher)
|
public function destroy(Voucher $voucher)
|
||||||
{
|
{
|
||||||
$voucher->delete();
|
$voucher->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('voucher has been removed!'));
|
return redirect()->back()->with('success', __('voucher has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function users(Voucher $voucher)
|
public function users(Voucher $voucher)
|
||||||
{
|
{
|
||||||
return view('admin.vouchers.users', [
|
return view('admin.vouchers.users', [
|
||||||
'voucher' => $voucher
|
'voucher' => $voucher,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function redeem(Request $request)
|
public function redeem(Request $request)
|
||||||
{
|
{
|
||||||
#general validations
|
//general validations
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => 'required|exists:vouchers,code'
|
'code' => 'required|exists:vouchers,code',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#get voucher by code
|
//get voucher by code
|
||||||
$voucher = Voucher::where('code', '=', $request->input('code'))->firstOrFail();
|
$voucher = Voucher::where('code', '=', $request->input('code'))->firstOrFail();
|
||||||
|
|
||||||
#extra validations
|
//extra validations
|
||||||
if ($voucher->getStatus() == 'USES_LIMIT_REACHED') throw ValidationException::withMessages([
|
if ($voucher->getStatus() == 'USES_LIMIT_REACHED') {
|
||||||
'code' => __('This voucher has reached the maximum amount of uses')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('This voucher has reached the maximum amount of uses'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($voucher->getStatus() == 'EXPIRED') throw ValidationException::withMessages([
|
if ($voucher->getStatus() == 'EXPIRED') {
|
||||||
'code' => __('This voucher has expired')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('This voucher has expired'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$request->user()->vouchers()->where('id', '=', $voucher->id)->get()->isEmpty()) throw ValidationException::withMessages([
|
if (! $request->user()->vouchers()->where('id', '=', $voucher->id)->get()->isEmpty()) {
|
||||||
'code' => __('You already redeemed this voucher code')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('You already redeemed this voucher code'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->user()->credits + $voucher->credits >= 99999999) throw ValidationException::withMessages([
|
if ($request->user()->credits + $voucher->credits >= 99999999) {
|
||||||
'code' => "You can't redeem this voucher because you would exceed the limit of " . CREDITS_DISPLAY_NAME
|
throw ValidationException::withMessages([
|
||||||
|
'code' => "You can't redeem this voucher because you would exceed the limit of ".CREDITS_DISPLAY_NAME,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
#redeem voucher
|
//redeem voucher
|
||||||
$voucher->redeem($request->user());
|
$voucher->redeem($request->user());
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($request->user()));
|
event(new UserUpdateCreditsEvent($request->user()));
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => "{$voucher->credits} " . CREDITS_DISPLAY_NAME ." ". __("have been added to your balance!")
|
'success' => "{$voucher->credits} ".CREDITS_DISPLAY_NAME.' '.__('have been added to your balance!'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,10 +181,10 @@ class VoucherController extends Controller
|
||||||
|
|
||||||
return datatables($users)
|
return datatables($users)
|
||||||
->editColumn('name', function (User $user) {
|
->editColumn('name', function (User $user) {
|
||||||
return '<a class="text-info" target="_blank" href="' . route('admin.users.show', $user->id) . '">' . $user->name . '</a>';
|
return '<a class="text-info" target="_blank" href="'.route('admin.users.show', $user->id).'">'.$user->name.'</a>';
|
||||||
})
|
})
|
||||||
->addColumn('credits', function (User $user) {
|
->addColumn('credits', function (User $user) {
|
||||||
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
|
return '<i class="fas fa-coins mr-2"></i> '.$user->credits();
|
||||||
})
|
})
|
||||||
->addColumn('last_seen', function (User $user) {
|
->addColumn('last_seen', function (User $user) {
|
||||||
return $user->last_seen ? $user->last_seen->diffForHumans() : '';
|
return $user->last_seen ? $user->last_seen->diffForHumans() : '';
|
||||||
|
@ -182,6 +192,7 @@ class VoucherController extends Controller
|
||||||
->rawColumns(['name', 'credits', 'last_seen'])
|
->rawColumns(['name', 'credits', 'last_seen'])
|
||||||
->make();
|
->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
{
|
{
|
||||||
$query = Voucher::query();
|
$query = Voucher::query();
|
||||||
|
@ -189,20 +200,23 @@ class VoucherController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (Voucher $voucher) {
|
->addColumn('actions', function (Voucher $voucher) {
|
||||||
return '
|
return '
|
||||||
<a data-content="'.__("Users").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.vouchers.users', $voucher->id) . '" class="btn btn-sm btn-primary mr-1"><i class="fas fa-users"></i></a>
|
<a data-content="'.__('Users').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.vouchers.users', $voucher->id).'" class="btn btn-sm btn-primary mr-1"><i class="fas fa-users"></i></a>
|
||||||
<a data-content="'.__("Edit").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.vouchers.edit', $voucher->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.vouchers.edit', $voucher->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
|
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.vouchers.destroy', $voucher->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.vouchers.destroy', $voucher->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->addColumn('status', function (Voucher $voucher) {
|
->addColumn('status', function (Voucher $voucher) {
|
||||||
$color = 'success';
|
$color = 'success';
|
||||||
if ($voucher->getStatus() != __('VALID')) $color = 'danger';
|
if ($voucher->getStatus() != __('VALID')) {
|
||||||
return '<span class="badge badge-' . $color . '">' . $voucher->getStatus() . '</span>';
|
$color = 'danger';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<span class="badge badge-'.$color.'">'.$voucher->getStatus().'</span>';
|
||||||
})
|
})
|
||||||
->editColumn('uses', function (Voucher $voucher) {
|
->editColumn('uses', function (Voucher $voucher) {
|
||||||
return "{$voucher->used} / {$voucher->uses}";
|
return "{$voucher->used} / {$voucher->uses}";
|
||||||
|
@ -211,7 +225,10 @@ class VoucherController extends Controller
|
||||||
return number_format($voucher->credits, 2, '.', '');
|
return number_format($voucher->credits, 2, '.', '');
|
||||||
})
|
})
|
||||||
->editColumn('expires_at', function (Voucher $voucher) {
|
->editColumn('expires_at', function (Voucher $voucher) {
|
||||||
if (!$voucher->expires_at) return "";
|
if (! $voucher->expires_at) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return $voucher->expires_at ? $voucher->expires_at->diffForHumans() : '';
|
return $voucher->expires_at ? $voucher->expires_at->diffForHumans() : '';
|
||||||
})
|
})
|
||||||
->editColumn('code', function (Voucher $voucher) {
|
->editColumn('code', function (Voucher $voucher) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ class NotificationController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display all notifications of an user.
|
* Display all notifications of an user.
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
* @return Response
|
* @return Response
|
||||||
|
@ -28,7 +29,7 @@ class NotificationController extends Controller
|
||||||
$discordUser = DiscordUser::find($userId);
|
$discordUser = DiscordUser::find($userId);
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
||||||
|
|
||||||
return $user->notifications()->paginate($request->query("per_page", 50));
|
return $user->notifications()->paginate($request->query('per_page', 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,10 +44,10 @@ class NotificationController extends Controller
|
||||||
$discordUser = DiscordUser::find($userId);
|
$discordUser = DiscordUser::find($userId);
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
||||||
|
|
||||||
$notification = $user->notifications()->where("id", $notificationId)->get()->first();
|
$notification = $user->notifications()->where('id', $notificationId)->get()->first();
|
||||||
|
|
||||||
if (!$notification) {
|
if (! $notification) {
|
||||||
return response()->json(["message" => "Notification not found."], 404);
|
return response()->json(['message' => 'Notification not found.'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notification;
|
return $notification;
|
||||||
|
@ -57,40 +58,41 @@ class NotificationController extends Controller
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function send(Request $request)
|
public function send(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
"via" => ["required", new Delimited("in:mail,database")],
|
'via' => ['required', new Delimited('in:mail,database')],
|
||||||
"all" => "required_without:users|boolean",
|
'all' => 'required_without:users|boolean',
|
||||||
"users" => ["required_without:all"],
|
'users' => ['required_without:all'],
|
||||||
"title" => "required|string|min:1",
|
'title' => 'required|string|min:1',
|
||||||
"content" => "required|string|min:1"
|
'content' => 'required|string|min:1',
|
||||||
]);
|
]);
|
||||||
$via = explode(",", $data["via"]);
|
$via = explode(',', $data['via']);
|
||||||
$mail = null;
|
$mail = null;
|
||||||
$database = null;
|
$database = null;
|
||||||
|
|
||||||
if (in_array("database", $via)) {
|
if (in_array('database', $via)) {
|
||||||
$database = [
|
$database = [
|
||||||
"title" => $data["title"],
|
'title' => $data['title'],
|
||||||
"content" => $data["content"]
|
'content' => $data['content'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (in_array("mail", $via)) {
|
if (in_array('mail', $via)) {
|
||||||
$mail = (new MailMessage)
|
$mail = (new MailMessage)
|
||||||
->subject($data["title"])
|
->subject($data['title'])
|
||||||
->line(new HtmlString($data["content"]));
|
->line(new HtmlString($data['content']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$all = $data["all"] ?? false;
|
$all = $data['all'] ?? false;
|
||||||
if ($all) {
|
if ($all) {
|
||||||
$users = User::all();
|
$users = User::all();
|
||||||
} else {
|
} else {
|
||||||
$userIds = explode(",", $data["users"]);
|
$userIds = explode(',', $data['users']);
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereIn("id", $userIds)
|
->whereIn('id', $userIds)
|
||||||
->orWhereHas('discordUser', function (Builder $builder) use ($userIds) {
|
->orWhereHas('discordUser', function (Builder $builder) use ($userIds) {
|
||||||
$builder->whereIn('id', $userIds);
|
$builder->whereIn('id', $userIds);
|
||||||
})
|
})
|
||||||
|
@ -104,7 +106,8 @@ class NotificationController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification::send($users, new DynamicNotification($via, $database, $mail));
|
Notification::send($users, new DynamicNotification($via, $database, $mail));
|
||||||
return response()->json(["message" => "Notification successfully sent.", 'user_count' => $users->count()]);
|
|
||||||
|
return response()->json(['message' => 'Notification successfully sent.', 'user_count' => $users->count()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,10 +123,9 @@ class NotificationController extends Controller
|
||||||
|
|
||||||
$count = $user->notifications()->delete();
|
$count = $user->notifications()->delete();
|
||||||
|
|
||||||
return response()->json(["message" => "All notifications have been successfully deleted.", "count" => $count]);
|
return response()->json(['message' => 'All notifications have been successfully deleted.', 'count' => $count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a specific notification
|
* Delete a specific notification
|
||||||
*
|
*
|
||||||
|
@ -136,13 +138,14 @@ class NotificationController extends Controller
|
||||||
$discordUser = DiscordUser::find($userId);
|
$discordUser = DiscordUser::find($userId);
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($userId);
|
||||||
|
|
||||||
$notification = $user->notifications()->where("id", $notificationid)->get()->first();
|
$notification = $user->notifications()->where('id', $notificationid)->get()->first();
|
||||||
|
|
||||||
if (!$notification) {
|
if (! $notification) {
|
||||||
return response()->json(["message" => "Notification not found."], 404);
|
return response()->json(['message' => 'Notification not found.'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification->delete();
|
$notification->delete();
|
||||||
|
|
||||||
return response()->json($notification);
|
return response()->json($notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Spatie\QueryBuilder\QueryBuilder;
|
||||||
class ServerController extends Controller
|
class ServerController extends Controller
|
||||||
{
|
{
|
||||||
public const ALLOWED_INCLUDES = ['product', 'user'];
|
public const ALLOWED_INCLUDES = ['product', 'user'];
|
||||||
|
|
||||||
public const ALLOWED_FILTERS = ['name', 'suspended', 'identifier', 'pterodactyl_id', 'user_id', 'product_id'];
|
public const ALLOWED_FILTERS = ['name', 'suspended', 'identifier', 'pterodactyl_id', 'user_id', 'product_id'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +37,6 @@ class ServerController extends Controller
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
*
|
|
||||||
* @return Server|Collection|Model
|
* @return Server|Collection|Model
|
||||||
*/
|
*/
|
||||||
public function show(Server $server)
|
public function show(Server $server)
|
||||||
|
@ -57,12 +57,13 @@ class ServerController extends Controller
|
||||||
public function destroy(Server $server)
|
public function destroy(Server $server)
|
||||||
{
|
{
|
||||||
$server->delete();
|
$server->delete();
|
||||||
|
|
||||||
return $server;
|
return $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* suspend server
|
* suspend server
|
||||||
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @return Server|JsonResponse
|
* @return Server|JsonResponse
|
||||||
*/
|
*/
|
||||||
|
@ -77,9 +78,9 @@ class ServerController extends Controller
|
||||||
return $server->load('product');
|
return $server->load('product');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unsuspend server
|
* unsuspend server
|
||||||
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @return Server|JsonResponse
|
* @return Server|JsonResponse
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,6 @@ use App\Classes\Pterodactyl;
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\DiscordUser;
|
use App\Models\DiscordUser;
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\ReferralNotification;
|
use App\Notifications\ReferralNotification;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -29,6 +28,7 @@ use Spatie\QueryBuilder\QueryBuilder;
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
const ALLOWED_INCLUDES = ['servers', 'notifications', 'payments', 'vouchers', 'discordUser'];
|
const ALLOWED_INCLUDES = ['servers', 'notifications', 'payments', 'vouchers', 'discordUser'];
|
||||||
|
|
||||||
const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'role', 'suspended'];
|
const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'role', 'suspended'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,12 +46,10 @@ class UserController extends Controller
|
||||||
return $query->paginate($request->input('per_page') ?? 50);
|
return $query->paginate($request->input('per_page') ?? 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return User|Builder|Collection|Model
|
* @return User|Builder|Collection|Model
|
||||||
*/
|
*/
|
||||||
public function show(int $id)
|
public function show(int $id)
|
||||||
|
@ -70,7 +68,6 @@ class UserController extends Controller
|
||||||
return $query->firstOrFail();
|
return $query->firstOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*
|
*
|
||||||
|
@ -84,28 +81,28 @@ class UserController extends Controller
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"name" => "sometimes|string|min:4|max:30",
|
'name' => 'sometimes|string|min:4|max:30',
|
||||||
"email" => "sometimes|string|email",
|
'email' => 'sometimes|string|email',
|
||||||
"credits" => "sometimes|numeric|min:0|max:1000000",
|
'credits' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
"server_limit" => "sometimes|numeric|min:0|max:1000000",
|
'server_limit' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
"role" => ['sometimes', Rule::in(['admin', 'moderator', 'client', 'member'])],
|
'role' => ['sometimes', Rule::in(['admin', 'moderator', 'client', 'member'])],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
//Update Users Password on Pterodactyl
|
//Update Users Password on Pterodactyl
|
||||||
//Username,Mail,First and Lastname are required aswell
|
//Username,Mail,First and Lastname are required aswell
|
||||||
$response = Pterodactyl::client()->patch('/application/users/' . $user->pterodactyl_id, [
|
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
||||||
"username" => $request->name,
|
'username' => $request->name,
|
||||||
"first_name" => $request->name,
|
'first_name' => $request->name,
|
||||||
"last_name" => $request->name,
|
'last_name' => $request->name,
|
||||||
"email" => $request->email,
|
'email' => $request->email,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
||||||
'pterodactyl_error_status' => $response->toException()->getCode()
|
'pterodactyl_error_status' => $response->toException()->getCode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$user->update($request->all());
|
$user->update($request->all());
|
||||||
|
@ -119,6 +116,7 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return User
|
* @return User
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function increment(Request $request, int $id)
|
public function increment(Request $request, int $id)
|
||||||
|
@ -127,22 +125,26 @@ class UserController extends Controller
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"credits" => "sometimes|numeric|min:0|max:1000000",
|
'credits' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
"server_limit" => "sometimes|numeric|min:0|max:1000000",
|
'server_limit' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->credits) {
|
if ($request->credits) {
|
||||||
if ($user->credits + $request->credits >= 99999999) throw ValidationException::withMessages([
|
if ($user->credits + $request->credits >= 99999999) {
|
||||||
'credits' => "You can't add this amount of credits because you would exceed the credit limit"
|
throw ValidationException::withMessages([
|
||||||
|
'credits' => "You can't add this amount of credits because you would exceed the credit limit",
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
$user->increment('credits', $request->credits);
|
$user->increment('credits', $request->credits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->server_limit) {
|
if ($request->server_limit) {
|
||||||
if ($user->server_limit + $request->server_limit >= 2147483647) throw ValidationException::withMessages([
|
if ($user->server_limit + $request->server_limit >= 2147483647) {
|
||||||
'server_limit' => "You cannot add this amount of servers because it would exceed the server limit."
|
throw ValidationException::withMessages([
|
||||||
|
'server_limit' => 'You cannot add this amount of servers because it would exceed the server limit.',
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
$user->increment('server_limit', $request->server_limit);
|
$user->increment('server_limit', $request->server_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +157,7 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return User
|
* @return User
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function decrement(Request $request, int $id)
|
public function decrement(Request $request, int $id)
|
||||||
|
@ -163,21 +166,25 @@ class UserController extends Controller
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"credits" => "sometimes|numeric|min:0|max:1000000",
|
'credits' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
"server_limit" => "sometimes|numeric|min:0|max:1000000",
|
'server_limit' => 'sometimes|numeric|min:0|max:1000000',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->credits) {
|
if ($request->credits) {
|
||||||
if ($user->credits - $request->credits < 0) throw ValidationException::withMessages([
|
if ($user->credits - $request->credits < 0) {
|
||||||
'credits' => "You can't remove this amount of credits because you would exceed the minimum credit limit"
|
throw ValidationException::withMessages([
|
||||||
|
'credits' => "You can't remove this amount of credits because you would exceed the minimum credit limit",
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
$user->decrement('credits', $request->credits);
|
$user->decrement('credits', $request->credits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->server_limit) {
|
if ($request->server_limit) {
|
||||||
if ($user->server_limit - $request->server_limit < 0) throw ValidationException::withMessages([
|
if ($user->server_limit - $request->server_limit < 0) {
|
||||||
'server_limit' => "You cannot remove this amount of servers because it would exceed the minimum server."
|
throw ValidationException::withMessages([
|
||||||
|
'server_limit' => 'You cannot remove this amount of servers because it would exceed the minimum server.',
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
$user->decrement('server_limit', $request->server_limit);
|
$user->decrement('server_limit', $request->server_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +197,7 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function suspend(Request $request, int $id)
|
public function suspend(Request $request, int $id)
|
||||||
|
@ -213,6 +221,7 @@ class UserController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function unsuspend(Request $request, int $id)
|
public function unsuspend(Request $request, int $id)
|
||||||
|
@ -220,9 +229,9 @@ class UserController extends Controller
|
||||||
$discordUser = DiscordUser::find($id);
|
$discordUser = DiscordUser::find($id);
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||||
|
|
||||||
if (!$user->isSuspended()) {
|
if (! $user->isSuspended()) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'error' => "You cannot unsuspend an User who is not suspended."
|
'error' => 'You cannot unsuspend an User who is not suspended.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,17 +239,22 @@ class UserController extends Controller
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a unique Referral Code for User
|
* Create a unique Referral Code for User
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function createReferralCode(){
|
protected function createReferralCode()
|
||||||
|
{
|
||||||
$referralcode = STR::random(8);
|
$referralcode = STR::random(8);
|
||||||
if (User::where('referral_code', '=', $referralcode)->exists()) {
|
if (User::where('referral_code', '=', $referralcode)->exists()) {
|
||||||
$this->createReferralCode();
|
$this->createReferralCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $referralcode;
|
return $referralcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
|
@ -253,9 +267,9 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Prevent the creation of new users via API if this is enabled.
|
// Prevent the creation of new users via API if this is enabled.
|
||||||
if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
|
if (! config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'error' => "The creation of new users has been blocked by the system administrator."
|
'error' => 'The creation of new users has been blocked by the system administrator.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,34 +283,34 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = Pterodactyl::client()->post('/application/users', [
|
$response = Pterodactyl::client()->post('/application/users', [
|
||||||
"external_id" => App::environment('local') ? Str::random(16) : (string)$user->id,
|
'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id,
|
||||||
"username" => $user->name,
|
'username' => $user->name,
|
||||||
"email" => $user->email,
|
'email' => $user->email,
|
||||||
"first_name" => $user->name,
|
'first_name' => $user->name,
|
||||||
"last_name" => $user->name,
|
'last_name' => $user->name,
|
||||||
"password" => $request->input('password'),
|
'password' => $request->input('password'),
|
||||||
"root_admin" => false,
|
'root_admin' => false,
|
||||||
"language" => "en"
|
'language' => 'en',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
$user->delete();
|
$user->delete();
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
||||||
'pterodactyl_error_status' => $response->toException()->getCode()
|
'pterodactyl_error_status' => $response->toException()->getCode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'pterodactyl_id' => $response->json()['attributes']['id']
|
'pterodactyl_id' => $response->json()['attributes']['id'],
|
||||||
]);
|
]);
|
||||||
//INCREMENT REFERRAL-USER CREDITS
|
//INCREMENT REFERRAL-USER CREDITS
|
||||||
if(!empty($request->input("referral_code"))){
|
if (! empty($request->input('referral_code'))) {
|
||||||
$ref_code = $request->input("referral_code");
|
$ref_code = $request->input('referral_code');
|
||||||
$new_user = $user->id;
|
$new_user = $user->id;
|
||||||
if($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|
if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|
||||||
if(config("SETTINGS::REFERRAL:MODE") == "register" || config("SETTINGS::REFERRAL:MODE") == "both") {
|
if (config('SETTINGS::REFERRAL:MODE') == 'register' || config('SETTINGS::REFERRAL:MODE') == 'both') {
|
||||||
$ref_user->increment('credits', config("SETTINGS::REFERRAL::REWARD"));
|
$ref_user->increment('credits', config('SETTINGS::REFERRAL::REWARD'));
|
||||||
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
|
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
|
||||||
}
|
}
|
||||||
//INSERT INTO USER_REFERRALS TABLE
|
//INSERT INTO USER_REFERRALS TABLE
|
||||||
|
@ -304,10 +318,9 @@ class UserController extends Controller
|
||||||
'referral_id' => $ref_user->id,
|
'referral_id' => $ref_user->id,
|
||||||
'registered_user_id' => $user->id,
|
'registered_user_id' => $user->id,
|
||||||
'created_at' => Carbon::now(),
|
'created_at' => Carbon::now(),
|
||||||
'updated_at' => Carbon::now()
|
'updated_at' => Carbon::now(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$user->sendEmailVerificationNotification();
|
$user->sendEmailVerificationNotification();
|
||||||
|
|
||||||
|
@ -326,6 +339,7 @@ class UserController extends Controller
|
||||||
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
||||||
|
|
||||||
$user->delete();
|
$user->delete();
|
||||||
|
|
||||||
return response($user, 200);
|
return response($user, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Spatie\QueryBuilder\QueryBuilder;
|
||||||
class VoucherController extends Controller
|
class VoucherController extends Controller
|
||||||
{
|
{
|
||||||
const ALLOWED_INCLUDES = ['users'];
|
const ALLOWED_INCLUDES = ['users'];
|
||||||
|
|
||||||
const ALLOWED_FILTERS = ['code', 'memo', 'credits', 'uses'];
|
const ALLOWED_FILTERS = ['code', 'memo', 'credits', 'uses'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +55,7 @@ class VoucherController extends Controller
|
||||||
'code' => 'required|string|alpha_dash|max:36|min:4|unique:vouchers',
|
'code' => 'required|string|alpha_dash|max:36|min:4|unique:vouchers',
|
||||||
'uses' => 'required|numeric|max:2147483647|min:1',
|
'uses' => 'required|numeric|max:2147483647|min:1',
|
||||||
'credits' => 'required|numeric|between:0,99999999',
|
'credits' => 'required|numeric|between:0,99999999',
|
||||||
'expires_at' => 'nullable|multiple_date_format:d-m-Y H:i:s,d-m-Y|after:now|before:10 years'
|
'expires_at' => 'nullable|multiple_date_format:d-m-Y H:i:s,d-m-Y|after:now|before:10 years',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Voucher::create($request->all());
|
return Voucher::create($request->all());
|
||||||
|
@ -64,7 +65,6 @@ class VoucherController extends Controller
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Voucher|Collection|Model
|
* @return Voucher|Collection|Model
|
||||||
*/
|
*/
|
||||||
public function show(int $id)
|
public function show(int $id)
|
||||||
|
@ -103,7 +103,7 @@ class VoucherController extends Controller
|
||||||
'code' => "required|string|alpha_dash|max:36|min:4|unique:vouchers,code,{$voucher->id}",
|
'code' => "required|string|alpha_dash|max:36|min:4|unique:vouchers,code,{$voucher->id}",
|
||||||
'uses' => 'required|numeric|max:2147483647|min:1',
|
'uses' => 'required|numeric|max:2147483647|min:1',
|
||||||
'credits' => 'required|numeric|between:0,99999999',
|
'credits' => 'required|numeric|between:0,99999999',
|
||||||
'expires_at' => 'nullable|multiple_date_format:d-m-Y H:i:s,d-m-Y|after:now|before:10 years'
|
'expires_at' => 'nullable|multiple_date_format:d-m-Y H:i:s,d-m-Y|after:now|before:10 years',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$voucher->update($request->all());
|
$voucher->update($request->all());
|
||||||
|
@ -121,12 +121,13 @@ class VoucherController extends Controller
|
||||||
{
|
{
|
||||||
$voucher = Voucher::findOrFail($id);
|
$voucher = Voucher::findOrFail($id);
|
||||||
$voucher->delete();
|
$voucher->delete();
|
||||||
|
|
||||||
return $voucher;
|
return $voucher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get linked users
|
* get linked users
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Voucher $voucher
|
* @param Voucher $voucher
|
||||||
* @return LengthAwarePaginator
|
* @return LengthAwarePaginator
|
||||||
|
@ -138,7 +139,7 @@ class VoucherController extends Controller
|
||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
Rule::in(['discorduser']),
|
Rule::in(['discorduser']),
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->input('include') == 'discorduser') {
|
if ($request->input('include') == 'discorduser') {
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ForgotPasswordController extends Controller
|
class ForgotPasswordController extends Controller
|
||||||
|
@ -32,7 +31,6 @@ class ForgotPasswordController extends Controller
|
||||||
$this->middleware('guest');
|
$this->middleware('guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function validateEmail(Request $request)
|
protected function validateEmail(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
|
@ -44,8 +42,5 @@ class ForgotPasswordController extends Controller
|
||||||
'g-recaptcha-response' => 'required|recaptcha',
|
'g-recaptcha-response' => 'required|recaptcha',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -44,7 +43,6 @@ class LoginController extends Controller
|
||||||
|
|
||||||
public function login(Request $request)
|
public function login(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$validationRules = [
|
$validationRules = [
|
||||||
$this->username() => 'required|string',
|
$this->username() => 'required|string',
|
||||||
'password' => 'required|string',
|
'password' => 'required|string',
|
||||||
|
@ -54,8 +52,6 @@ class LoginController extends Controller
|
||||||
}
|
}
|
||||||
$request->validate($validationRules);
|
$request->validate($validationRules);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||||
// the login attempts for this application. We'll key this by the username and
|
// the login attempts for this application. We'll key this by the username and
|
||||||
// the IP address of the client making these requests into this application.
|
// the IP address of the client making these requests into this application.
|
||||||
|
@ -72,6 +68,7 @@ class LoginController extends Controller
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$user->last_seen = now();
|
$user->last_seen = now();
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
return $this->sendLoginResponse($request);
|
return $this->sendLoginResponse($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,12 @@ namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Classes\Pterodactyl;
|
use App\Classes\Pterodactyl;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\ReferralNotification;
|
use App\Notifications\ReferralNotification;
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
@ -75,10 +73,13 @@ class RegisterController extends Controller
|
||||||
|
|
||||||
//check if ip has already made an account
|
//check if ip has already made an account
|
||||||
$data['ip'] = session()->get('ip') ?? request()->ip();
|
$data['ip'] = session()->get('ip') ?? request()->ip();
|
||||||
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
if (User::where('ip', '=', request()->ip())->exists()) {
|
||||||
|
session()->put('ip', request()->ip());
|
||||||
|
}
|
||||||
$validationRules['ip'] = ['unique:users'];
|
$validationRules['ip'] = ['unique:users'];
|
||||||
|
|
||||||
return Validator::make($data, $validationRules, [
|
return Validator::make($data, $validationRules, [
|
||||||
'ip.unique' => "You have already made an account! Please contact support if you think this is incorrect."
|
'ip.unique' => 'You have already made an account! Please contact support if you think this is incorrect.',
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -88,13 +89,16 @@ class RegisterController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a unique Referral Code for User
|
* Create a unique Referral Code for User
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function createReferralCode(){
|
protected function createReferralCode()
|
||||||
|
{
|
||||||
$referralcode = STR::random(8);
|
$referralcode = STR::random(8);
|
||||||
if (User::where('referral_code', '=', $referralcode)->exists()) {
|
if (User::where('referral_code', '=', $referralcode)->exists()) {
|
||||||
$this->createReferralCode();
|
$this->createReferralCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $referralcode;
|
return $referralcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,14 +121,14 @@ class RegisterController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = Pterodactyl::client()->post('/application/users', [
|
$response = Pterodactyl::client()->post('/application/users', [
|
||||||
"external_id" => App::environment('local') ? Str::random(16) : (string)$user->id,
|
'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id,
|
||||||
"username" => $user->name,
|
'username' => $user->name,
|
||||||
"email" => $user->email,
|
'email' => $user->email,
|
||||||
"first_name" => $user->name,
|
'first_name' => $user->name,
|
||||||
"last_name" => $user->name,
|
'last_name' => $user->name,
|
||||||
"password" => $data['password'],
|
'password' => $data['password'],
|
||||||
"root_admin" => false,
|
'root_admin' => false,
|
||||||
"language" => "en"
|
'language' => 'en',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
|
@ -135,33 +139,32 @@ class RegisterController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'pterodactyl_id' => $response->json()['attributes']['id']
|
'pterodactyl_id' => $response->json()['attributes']['id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//INCREMENT REFERRAL-USER CREDITS
|
//INCREMENT REFERRAL-USER CREDITS
|
||||||
if(!empty($data['referral_code'])){
|
if (! empty($data['referral_code'])) {
|
||||||
$ref_code = $data['referral_code'];
|
$ref_code = $data['referral_code'];
|
||||||
$new_user = $user->id;
|
$new_user = $user->id;
|
||||||
if($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|
if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|
||||||
if(config("SETTINGS::REFERRAL:MODE") == "sign-up" || config("SETTINGS::REFERRAL:MODE") == "both") {
|
if (config('SETTINGS::REFERRAL:MODE') == 'sign-up' || config('SETTINGS::REFERRAL:MODE') == 'both') {
|
||||||
$ref_user->increment('credits', config("SETTINGS::REFERRAL::REWARD"));
|
$ref_user->increment('credits', config('SETTINGS::REFERRAL::REWARD'));
|
||||||
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
|
$ref_user->notify(new ReferralNotification($ref_user->id, $new_user));
|
||||||
|
|
||||||
//LOGS REFERRALS IN THE ACTIVITY LOG
|
//LOGS REFERRALS IN THE ACTIVITY LOG
|
||||||
activity()
|
activity()
|
||||||
->performedOn($user)
|
->performedOn($user)
|
||||||
->causedBy($ref_user)
|
->causedBy($ref_user)
|
||||||
->log('gained '. config("SETTINGS::REFERRAL::REWARD").' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for sign-up-referral of '.$user->name.' (ID:'.$user->id.')');
|
->log('gained '.config('SETTINGS::REFERRAL::REWARD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').' for sign-up-referral of '.$user->name.' (ID:'.$user->id.')');
|
||||||
}
|
}
|
||||||
//INSERT INTO USER_REFERRALS TABLE
|
//INSERT INTO USER_REFERRALS TABLE
|
||||||
DB::table('user_referrals')->insert([
|
DB::table('user_referrals')->insert([
|
||||||
'referral_id' => $ref_user->id,
|
'referral_id' => $ref_user->id,
|
||||||
'registered_user_id' => $user->id,
|
'registered_user_id' => $user->id,
|
||||||
'created_at' => Carbon::now(),
|
'created_at' => Carbon::now(),
|
||||||
'updated_at' => Carbon::now()
|
'updated_at' => Carbon::now(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|
|
@ -4,10 +4,7 @@ namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\DiscordUser;
|
use App\Models\DiscordUser;
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Voucher;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Laravel\Socialite\Facades\Socialite;
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
@ -16,7 +13,7 @@ class SocialiteController extends Controller
|
||||||
{
|
{
|
||||||
public function redirect()
|
public function redirect()
|
||||||
{
|
{
|
||||||
$scopes = !empty(config("SETTINGS::DISCORD:BOT_TOKEN")) && !empty(config("SETTINGS::DISCORD:GUILD_ID")) ? ['guilds.join'] : [];
|
$scopes = ! empty(config('SETTINGS::DISCORD:BOT_TOKEN')) && ! empty(config('SETTINGS::DISCORD:GUILD_ID')) ? ['guilds.join'] : [];
|
||||||
|
|
||||||
return Socialite::driver('discord')
|
return Socialite::driver('discord')
|
||||||
->scopes($scopes)
|
->scopes($scopes)
|
||||||
|
@ -32,9 +29,9 @@ class SocialiteController extends Controller
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$discord = Socialite::driver('discord')->user();
|
$discord = Socialite::driver('discord')->user();
|
||||||
$botToken = config("SETTINGS::DISCORD:BOT_TOKEN");
|
$botToken = config('SETTINGS::DISCORD:BOT_TOKEN');
|
||||||
$guildId = config("SETTINGS::DISCORD:GUILD_ID");
|
$guildId = config('SETTINGS::DISCORD:GUILD_ID');
|
||||||
$roleId = config("SETTINGS::DISCORD:ROLE_ID");
|
$roleId = config('SETTINGS::DISCORD:ROLE_ID');
|
||||||
|
|
||||||
//save / update discord_users
|
//save / update discord_users
|
||||||
|
|
||||||
|
@ -55,17 +52,16 @@ class SocialiteController extends Controller
|
||||||
Auth::user()->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
|
Auth::user()->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
|
||||||
Auth::user()->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
|
Auth::user()->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
|
||||||
Auth::user()->update(['discord_verified_at' => now()]);
|
Auth::user()->update(['discord_verified_at' => now()]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$user->discordUser->update($discord->user);
|
$user->discordUser->update($discord->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
//force user into discord server
|
//force user into discord server
|
||||||
//TODO Add event on failure, to notify ppl involved
|
//TODO Add event on failure, to notify ppl involved
|
||||||
if (!empty($guildId) && !empty($botToken)) {
|
if (! empty($guildId) && ! empty($botToken)) {
|
||||||
$response = Http::withHeaders(
|
$response = Http::withHeaders(
|
||||||
[
|
[
|
||||||
'Authorization' => 'Bot ' . $botToken,
|
'Authorization' => 'Bot '.$botToken,
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
]
|
]
|
||||||
)->put(
|
)->put(
|
||||||
|
@ -74,10 +70,10 @@ class SocialiteController extends Controller
|
||||||
);
|
);
|
||||||
|
|
||||||
//give user a role in the discord server
|
//give user a role in the discord server
|
||||||
if (!empty($roleId)) {
|
if (! empty($roleId)) {
|
||||||
$response = Http::withHeaders(
|
$response = Http::withHeaders(
|
||||||
[
|
[
|
||||||
'Authorization' => 'Bot ' . $botToken,
|
'Authorization' => 'Bot '.$botToken,
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
]
|
]
|
||||||
)->put(
|
)->put(
|
||||||
|
|
|
@ -12,22 +12,26 @@ use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
const TIME_LEFT_BG_SUCCESS = "bg-success";
|
const TIME_LEFT_BG_SUCCESS = 'bg-success';
|
||||||
const TIME_LEFT_BG_WARNING = "bg-warning";
|
|
||||||
const TIME_LEFT_BG_DANGER = "bg-danger";
|
const TIME_LEFT_BG_WARNING = 'bg-warning';
|
||||||
|
|
||||||
|
const TIME_LEFT_BG_DANGER = 'bg-danger';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callHome(){
|
public function callHome()
|
||||||
if(Storage::exists("callHome")){return;}
|
{
|
||||||
|
if (Storage::exists('callHome')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Http::asForm()->post('https://market.controlpanel.gg/callhome.php', [
|
Http::asForm()->post('https://market.controlpanel.gg/callhome.php', [
|
||||||
'id' => Hash::make(URL::current())
|
'id' => Hash::make(URL::current()),
|
||||||
]);
|
]);
|
||||||
Storage::put('callHome', 'This is only used to count the installations of cpgg.');
|
Storage::put('callHome', 'This is only used to count the installations of cpgg.');
|
||||||
}
|
}
|
||||||
|
@ -36,7 +40,6 @@ class HomeController extends Controller
|
||||||
* @description Get the Background Color for the Days-Left-Box in HomeView
|
* @description Get the Background Color for the Days-Left-Box in HomeView
|
||||||
*
|
*
|
||||||
* @param float $daysLeft
|
* @param float $daysLeft
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTimeLeftBoxBackground(float $daysLeft): string
|
public function getTimeLeftBoxBackground(float $daysLeft): string
|
||||||
|
@ -47,22 +50,24 @@ class HomeController extends Controller
|
||||||
if ($daysLeft <= 7) {
|
if ($daysLeft <= 7) {
|
||||||
return $this::TIME_LEFT_BG_DANGER;
|
return $this::TIME_LEFT_BG_DANGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this::TIME_LEFT_BG_WARNING;
|
return $this::TIME_LEFT_BG_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Set "hours", "days" or nothing behind the remaining time
|
* @description Set "hours", "days" or nothing behind the remaining time
|
||||||
*
|
*
|
||||||
* @param float $daysLeft
|
* @param float $daysLeft
|
||||||
* @param float $hoursLeft
|
* @param float $hoursLeft
|
||||||
*
|
|
||||||
* @return string|void
|
* @return string|void
|
||||||
*/
|
*/
|
||||||
public function getTimeLeftBoxUnit(float $daysLeft, float $hoursLeft)
|
public function getTimeLeftBoxUnit(float $daysLeft, float $hoursLeft)
|
||||||
{
|
{
|
||||||
if ($daysLeft > 1) return __('days');
|
if ($daysLeft > 1) {
|
||||||
return $hoursLeft < 1 ? null : __("hours");
|
return __('days');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hoursLeft < 1 ? null : __('hours');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,13 +75,15 @@ class HomeController extends Controller
|
||||||
*
|
*
|
||||||
* @param float $daysLeft
|
* @param float $daysLeft
|
||||||
* @param float $hoursLeft
|
* @param float $hoursLeft
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTimeLeftBoxText(float $daysLeft, float $hoursLeft)
|
public function getTimeLeftBoxText(float $daysLeft, float $hoursLeft)
|
||||||
{
|
{
|
||||||
if ($daysLeft > 1) return strval(number_format($daysLeft, 0));
|
if ($daysLeft > 1) {
|
||||||
return ($hoursLeft < 1 ? __("You ran out of Credits") : strval($hoursLeft));
|
return strval(number_format($daysLeft, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hoursLeft < 1 ? __('You ran out of Credits') : strval($hoursLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show the application dashboard. */
|
/** Show the application dashboard. */
|
||||||
|
@ -84,9 +91,9 @@ class HomeController extends Controller
|
||||||
{
|
{
|
||||||
$usage = Auth::user()->creditUsage();
|
$usage = Auth::user()->creditUsage();
|
||||||
$credits = Auth::user()->Credits();
|
$credits = Auth::user()->Credits();
|
||||||
$bg = "";
|
$bg = '';
|
||||||
$boxText = "";
|
$boxText = '';
|
||||||
$unit = "";
|
$unit = '';
|
||||||
|
|
||||||
/** Build our Time-Left-Box */
|
/** Build our Time-Left-Box */
|
||||||
if ($credits > 0.01 and $usage > 0) {
|
if ($credits > 0.01 and $usage > 0) {
|
||||||
|
@ -95,7 +102,7 @@ class HomeController extends Controller
|
||||||
|
|
||||||
$bg = $this->getTimeLeftBoxBackground($daysLeft);
|
$bg = $this->getTimeLeftBoxBackground($daysLeft);
|
||||||
$boxText = $this->getTimeLeftBoxText($daysLeft, $hoursLeft);
|
$boxText = $this->getTimeLeftBoxText($daysLeft, $hoursLeft);
|
||||||
$unit = $daysLeft < 1 ? ($hoursLeft < 1 ? null : __("hours")) : __("days");
|
$unit = $daysLeft < 1 ? ($hoursLeft < 1 ? null : __('hours')) : __('days');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->callhome();
|
$this->callhome();
|
||||||
|
@ -108,9 +115,9 @@ class HomeController extends Controller
|
||||||
'bg' => $bg,
|
'bg' => $bg,
|
||||||
'boxText' => $boxText,
|
'boxText' => $boxText,
|
||||||
'unit' => $unit,
|
'unit' => $unit,
|
||||||
'numberOfReferrals' => DB::table('user_referrals')->where("referral_id","=",Auth::user()->id)->count(),
|
'numberOfReferrals' => DB::table('user_referrals')->where('referral_id', '=', Auth::user()->id)->count(),
|
||||||
'partnerDiscount' => PartnerDiscount::where('user_id', Auth::user()->id)->first(),
|
'partnerDiscount' => PartnerDiscount::where('user_id', Auth::user()->id)->first(),
|
||||||
'myDiscount' => PartnerDiscount::getDiscount()
|
'myDiscount' => PartnerDiscount::getDiscount(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,63 +2,71 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Moderation;
|
namespace App\Http\Controllers\Moderation;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Ticket;
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Models\TicketBlacklist;
|
||||||
use App\Models\TicketCategory;
|
use App\Models\TicketCategory;
|
||||||
use App\Models\TicketComment;
|
use App\Models\TicketComment;
|
||||||
use App\Models\TicketBlacklist;
|
use App\Models\User;
|
||||||
|
use App\Notifications\Ticket\User\ReplyNotification;
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use App\Notifications\Ticket\User\ReplyNotification;
|
|
||||||
|
|
||||||
class TicketsController extends Controller
|
class TicketsController extends Controller
|
||||||
{
|
{
|
||||||
public function index() {
|
public function index()
|
||||||
$tickets = Ticket::orderBy('id','desc')->paginate(10);
|
{
|
||||||
|
$tickets = Ticket::orderBy('id', 'desc')->paginate(10);
|
||||||
$ticketcategories = TicketCategory::all();
|
$ticketcategories = TicketCategory::all();
|
||||||
return view("moderator.ticket.index", compact("tickets", "ticketcategories"));
|
|
||||||
|
return view('moderator.ticket.index', compact('tickets', 'ticketcategories'));
|
||||||
}
|
}
|
||||||
public function show($ticket_id) {
|
|
||||||
$ticket = Ticket::where("ticket_id", $ticket_id)->firstOrFail();
|
public function show($ticket_id)
|
||||||
|
{
|
||||||
|
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||||
$ticketcomments = $ticket->ticketcomments;
|
$ticketcomments = $ticket->ticketcomments;
|
||||||
$ticketcategory = $ticket->ticketcategory;
|
$ticketcategory = $ticket->ticketcategory;
|
||||||
$server = Server::where('id', $ticket->server)->first();
|
$server = Server::where('id', $ticket->server)->first();
|
||||||
return view("moderator.ticket.show", compact("ticket", "ticketcategory", "ticketcomments", "server"));
|
|
||||||
|
return view('moderator.ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close($ticket_id) {
|
public function close($ticket_id)
|
||||||
$ticket = Ticket::where("ticket_id", $ticket_id)->firstOrFail();
|
{
|
||||||
$ticket->status = "Closed";
|
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||||
|
$ticket->status = 'Closed';
|
||||||
$ticket->save();
|
$ticket->save();
|
||||||
$ticketOwner = $ticket->user;
|
$ticketOwner = $ticket->user;
|
||||||
return redirect()->back()->with('success', __('A ticket has been closed, ID: #') . $ticket->ticket_id);
|
|
||||||
|
return redirect()->back()->with('success', __('A ticket has been closed, ID: #').$ticket->ticket_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($ticket_id){
|
public function delete($ticket_id)
|
||||||
$ticket = Ticket::where("ticket_id", $ticket_id)->firstOrFail();
|
{
|
||||||
TicketComment::where("ticket_id", $ticket->id)->delete();
|
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||||
|
TicketComment::where('ticket_id', $ticket->id)->delete();
|
||||||
$ticket->delete();
|
$ticket->delete();
|
||||||
return redirect()->back()->with('success', __('A ticket has been deleted, ID: #') . $ticket_id);
|
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', __('A ticket has been deleted, ID: #').$ticket_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reply(Request $request) {
|
public function reply(Request $request)
|
||||||
$this->validate($request, array("ticketcomment" => "required"));
|
{
|
||||||
$ticket = Ticket::where('id', $request->input("ticket_id"))->firstOrFail();
|
$this->validate($request, ['ticketcomment' => 'required']);
|
||||||
$ticket->status = "Answered";
|
$ticket = Ticket::where('id', $request->input('ticket_id'))->firstOrFail();
|
||||||
|
$ticket->status = 'Answered';
|
||||||
$ticket->update();
|
$ticket->update();
|
||||||
TicketComment::create(array(
|
TicketComment::create([
|
||||||
"ticket_id" => $request->input("ticket_id"),
|
'ticket_id' => $request->input('ticket_id'),
|
||||||
"user_id" => Auth::user()->id,
|
'user_id' => Auth::user()->id,
|
||||||
"ticketcomment" => $request->input("ticketcomment"),
|
'ticketcomment' => $request->input('ticketcomment'),
|
||||||
));
|
]);
|
||||||
$user = User::where('id', $ticket->user_id)->firstOrFail();
|
$user = User::where('id', $ticket->user_id)->firstOrFail();
|
||||||
$newmessage = $request->input("ticketcomment");
|
$newmessage = $request->input('ticketcomment');
|
||||||
$user->notify(new ReplyNotification($ticket, $user, $newmessage));
|
$user->notify(new ReplyNotification($ticket, $user, $newmessage));
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Your comment has been submitted'));
|
return redirect()->back()->with('success', __('Your comment has been submitted'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,23 +79,23 @@ class TicketsController extends Controller
|
||||||
return $tickets->ticketcategory->name;
|
return $tickets->ticketcategory->name;
|
||||||
})
|
})
|
||||||
->editColumn('title', function (Ticket $tickets) {
|
->editColumn('title', function (Ticket $tickets) {
|
||||||
return '<a class="text-info" href="' . route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]) . '">' . "#" . $tickets->ticket_id . " - " . $tickets->title . '</a>';
|
return '<a class="text-info" href="'.route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]).'">'.'#'.$tickets->ticket_id.' - '.$tickets->title.'</a>';
|
||||||
})
|
})
|
||||||
->editColumn('user_id', function (Ticket $tickets) {
|
->editColumn('user_id', function (Ticket $tickets) {
|
||||||
return '<a href="' . route('admin.users.show', $tickets->user->id) . '">' . $tickets->user->name . '</a>';
|
return '<a href="'.route('admin.users.show', $tickets->user->id).'">'.$tickets->user->name.'</a>';
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (Ticket $tickets) {
|
->addColumn('actions', function (Ticket $tickets) {
|
||||||
return '
|
return '
|
||||||
<a data-content="'.__("View").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]) . '" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-eye"></i></a>
|
<a data-content="'.__('View').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]).'" class="btn btn-sm text-white btn-info mr-1"><i class="fas fa-eye"></i></a>
|
||||||
<form class="d-inline" method="post" action="' . route('moderator.ticket.close', ['ticket_id' => $tickets->ticket_id ]) . '">
|
<form class="d-inline" method="post" action="'.route('moderator.ticket.close', ['ticket_id' => $tickets->ticket_id]).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("POST") . '
|
'.method_field('POST').'
|
||||||
<button data-content="'.__("Close").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-times"></i></button>
|
<button data-content="'.__('Close').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-times"></i></button>
|
||||||
</form>
|
</form>
|
||||||
<form class="d-inline" method="post" action="' . route('moderator.ticket.delete', ['ticket_id' => $tickets->ticket_id ]) . '">
|
<form class="d-inline" method="post" action="'.route('moderator.ticket.delete', ['ticket_id' => $tickets->ticket_id]).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("POST") . '
|
'.method_field('POST').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
|
@ -107,7 +115,7 @@ class TicketsController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="badge ' . $badgeColor . '">' . $tickets->status . '</span>';
|
return '<span class="badge '.$badgeColor.'">'.$tickets->status.'</span>';
|
||||||
})
|
})
|
||||||
->editColumn('priority', function (Ticket $tickets) {
|
->editColumn('priority', function (Ticket $tickets) {
|
||||||
return __($tickets->priority);
|
return __($tickets->priority);
|
||||||
|
@ -120,84 +128,89 @@ class TicketsController extends Controller
|
||||||
->make(true);
|
->make(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blacklist() {
|
public function blacklist()
|
||||||
return view("moderator.ticket.blacklist");
|
{
|
||||||
|
return view('moderator.ticket.blacklist');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blacklistAdd(Request $request) {
|
public function blacklistAdd(Request $request)
|
||||||
|
{
|
||||||
$user = User::where('id', $request->user_id)->first();
|
$user = User::where('id', $request->user_id)->first();
|
||||||
$check = TicketBlacklist::where('user_id', $user->id)->first();
|
$check = TicketBlacklist::where('user_id', $user->id)->first();
|
||||||
if($check){
|
if ($check) {
|
||||||
$check->reason = $request->reason;
|
$check->reason = $request->reason;
|
||||||
$check->status = "True";
|
$check->status = 'True';
|
||||||
$check->save();
|
$check->save();
|
||||||
|
|
||||||
return redirect()->back()->with('info', __('Target User already in blacklist. Reason updated'));
|
return redirect()->back()->with('info', __('Target User already in blacklist. Reason updated'));
|
||||||
}
|
}
|
||||||
TicketBlacklist::create(array(
|
TicketBlacklist::create([
|
||||||
"user_id" => $user->id,
|
'user_id' => $user->id,
|
||||||
"status" => "True",
|
'status' => 'True',
|
||||||
"reason" => $request->reason,
|
'reason' => $request->reason,
|
||||||
));
|
]);
|
||||||
return redirect()->back()->with('success', __('Successfully add User to blacklist, User name: ' . $user->name));
|
|
||||||
|
return redirect()->back()->with('success', __('Successfully add User to blacklist, User name: '.$user->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function blacklistDelete($id)
|
||||||
public function blacklistDelete($id) {
|
{
|
||||||
$blacklist = TicketBlacklist::where('id', $id)->first();
|
$blacklist = TicketBlacklist::where('id', $id)->first();
|
||||||
$blacklist->delete();
|
$blacklist->delete();
|
||||||
return redirect()->back()->with('success', __('Successfully remove User from blacklist, User name: ' . $blacklist->user->name));
|
|
||||||
|
return redirect()->back()->with('success', __('Successfully remove User from blacklist, User name: '.$blacklist->user->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blacklistChange($id) {
|
public function blacklistChange($id)
|
||||||
$blacklist = TicketBlacklist::where('id', $id)->first();
|
|
||||||
if($blacklist->status == "True")
|
|
||||||
{
|
{
|
||||||
$blacklist->status = "False";
|
$blacklist = TicketBlacklist::where('id', $id)->first();
|
||||||
|
if ($blacklist->status == 'True') {
|
||||||
|
$blacklist->status = 'False';
|
||||||
} else {
|
} else {
|
||||||
$blacklist->status = "True";
|
$blacklist->status = 'True';
|
||||||
}
|
}
|
||||||
$blacklist->update();
|
$blacklist->update();
|
||||||
return redirect()->back()->with('success', __('Successfully change status blacklist from, User name: ' . $blacklist->user->name));
|
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', __('Successfully change status blacklist from, User name: '.$blacklist->user->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTableBlacklist()
|
public function dataTableBlacklist()
|
||||||
{
|
{
|
||||||
$query = TicketBlacklist::with(['user']);
|
$query = TicketBlacklist::with(['user']);
|
||||||
$query->select('ticket_blacklists.*');
|
$query->select('ticket_blacklists.*');
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->editColumn('user', function (TicketBlacklist $blacklist) {
|
->editColumn('user', function (TicketBlacklist $blacklist) {
|
||||||
return '<a href="' . route('admin.users.show', $blacklist->user->id) . '">' . $blacklist->user->name . '</a>';
|
return '<a href="'.route('admin.users.show', $blacklist->user->id).'">'.$blacklist->user->name.'</a>';
|
||||||
})
|
})
|
||||||
->editColumn('status', function (TicketBlacklist $blacklist) {
|
->editColumn('status', function (TicketBlacklist $blacklist) {
|
||||||
switch ($blacklist->status) {
|
switch ($blacklist->status) {
|
||||||
case 'True':
|
case 'True':
|
||||||
$text = "Blocked";
|
$text = 'Blocked';
|
||||||
$badgeColor = 'badge-danger';
|
$badgeColor = 'badge-danger';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$text = "Unblocked";
|
$text = 'Unblocked';
|
||||||
$badgeColor = 'badge-success';
|
$badgeColor = 'badge-success';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="badge ' . $badgeColor . '">' . $text . '</span>';
|
return '<span class="badge '.$badgeColor.'">'.$text.'</span>';
|
||||||
})
|
})
|
||||||
->editColumn('reason', function (TicketBlacklist $blacklist) {
|
->editColumn('reason', function (TicketBlacklist $blacklist) {
|
||||||
return $blacklist->reason;
|
return $blacklist->reason;
|
||||||
})
|
})
|
||||||
->addColumn('actions', function (TicketBlacklist $blacklist) {
|
->addColumn('actions', function (TicketBlacklist $blacklist) {
|
||||||
return '
|
return '
|
||||||
<form class="d-inline" method="post" action="' . route('moderator.ticket.blacklist.change', ['id' => $blacklist->id ]) . '">
|
<form class="d-inline" method="post" action="'.route('moderator.ticket.blacklist.change', ['id' => $blacklist->id]).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("POST") . '
|
'.method_field('POST').'
|
||||||
<button data-content="'.__("Change Status").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-sync-alt"></i></button>
|
<button data-content="'.__('Change Status').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-sync-alt"></i></button>
|
||||||
</form>
|
</form>
|
||||||
<form class="d-inline" method="post" action="' . route('moderator.ticket.blacklist.delete', ['id' => $blacklist->id ]) . '">
|
<form class="d-inline" method="post" action="'.route('moderator.ticket.blacklist.delete', ['id' => $blacklist->id]).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("POST") . '
|
'.method_field('POST').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
|
@ -207,5 +220,4 @@ class TicketsController extends Controller
|
||||||
->rawColumns(['user', 'status', 'reason', 'created_at', 'actions'])
|
->rawColumns(['user', 'status', 'reason', 'created_at', 'actions'])
|
||||||
->make(true);
|
->make(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@ class NotificationController extends Controller
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$notifications = Auth::user()->notifications()->paginate();
|
$notifications = Auth::user()->notifications()->paginate();
|
||||||
|
|
||||||
return view('notifications.index')->with([
|
return view('notifications.index')->with([
|
||||||
'notifications' => $notifications
|
'notifications' => $notifications,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +22,19 @@ class NotificationController extends Controller
|
||||||
$notification = Auth::user()->notifications()->findOrFail($id);
|
$notification = Auth::user()->notifications()->findOrFail($id);
|
||||||
|
|
||||||
$notification->markAsRead();
|
$notification->markAsRead();
|
||||||
|
|
||||||
return view('notifications.show')->with([
|
return view('notifications.show')->with([
|
||||||
'notification' => $notification
|
'notification' => $notification,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readAll(){
|
public function readAll()
|
||||||
|
{
|
||||||
$notifications = Auth::user()->notifications()->get();
|
$notifications = Auth::user()->notifications()->get();
|
||||||
foreach($notifications as $notification){
|
foreach ($notifications as $notification) {
|
||||||
$notification->markAsRead();
|
$notification->markAsRead();
|
||||||
}
|
}
|
||||||
return redirect()->back();
|
|
||||||
|
|
||||||
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ class PartnerController extends Controller
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('admin.partners.create', [
|
return view('admin.partners.create', [
|
||||||
'partners' =>PartnerDiscount::get(),
|
'partners' => PartnerDiscount::get(),
|
||||||
'users' => User::orderBy('name')->get()
|
'users' => User::orderBy('name')->get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class PartnerController extends Controller
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'user_id' => 'required|integer|min:0',
|
'user_id' => 'required|integer|min:0',
|
||||||
'partner_discount' => 'required|integer|max:100|min:0',
|
'partner_discount' => 'required|integer|max:100|min:0',
|
||||||
'registered_user_discount' => 'required|integer|max:100|min:0'
|
'registered_user_discount' => 'required|integer|max:100|min:0',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
PartnerDiscount::create($request->all());
|
PartnerDiscount::create($request->all());
|
||||||
|
@ -65,9 +65,9 @@ class PartnerController extends Controller
|
||||||
public function edit(PartnerDiscount $partner)
|
public function edit(PartnerDiscount $partner)
|
||||||
{
|
{
|
||||||
return view('admin.partners.edit', [
|
return view('admin.partners.edit', [
|
||||||
'partners' =>PartnerDiscount::get(),
|
'partners' => PartnerDiscount::get(),
|
||||||
'partner' => $partner,
|
'partner' => $partner,
|
||||||
'users' => User::orderBy('name')->get()
|
'users' => User::orderBy('name')->get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class PartnerController extends Controller
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'user_id' => 'required|integer|min:0',
|
'user_id' => 'required|integer|min:0',
|
||||||
'partner_discount' => 'required|integer|max:100|min:0',
|
'partner_discount' => 'required|integer|max:100|min:0',
|
||||||
'registered_user_discount' => 'required|integer|max:100|min:0'
|
'registered_user_discount' => 'required|integer|max:100|min:0',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$partner->update($request->all());
|
$partner->update($request->all());
|
||||||
|
@ -101,55 +101,65 @@ class PartnerController extends Controller
|
||||||
public function destroy(PartnerDiscount $partner)
|
public function destroy(PartnerDiscount $partner)
|
||||||
{
|
{
|
||||||
$partner->delete();
|
$partner->delete();
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('partner has been removed!'));
|
return redirect()->back()->with('success', __('partner has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function users(Voucher $voucher)
|
public function users(Voucher $voucher)
|
||||||
{
|
{
|
||||||
return view('admin.vouchers.users', [
|
return view('admin.vouchers.users', [
|
||||||
'voucher' => $voucher
|
'voucher' => $voucher,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function redeem(Request $request)
|
public function redeem(Request $request)
|
||||||
{
|
{
|
||||||
#general validations
|
//general validations
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => 'required|exists:vouchers,code'
|
'code' => 'required|exists:vouchers,code',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#get voucher by code
|
//get voucher by code
|
||||||
$voucher = Voucher::where('code', '=', $request->input('code'))->firstOrFail();
|
$voucher = Voucher::where('code', '=', $request->input('code'))->firstOrFail();
|
||||||
|
|
||||||
#extra validations
|
//extra validations
|
||||||
if ($voucher->getStatus() == 'USES_LIMIT_REACHED') throw ValidationException::withMessages([
|
if ($voucher->getStatus() == 'USES_LIMIT_REACHED') {
|
||||||
'code' => __('This voucher has reached the maximum amount of uses')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('This voucher has reached the maximum amount of uses'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($voucher->getStatus() == 'EXPIRED') throw ValidationException::withMessages([
|
if ($voucher->getStatus() == 'EXPIRED') {
|
||||||
'code' => __('This voucher has expired')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('This voucher has expired'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$request->user()->vouchers()->where('id', '=', $voucher->id)->get()->isEmpty()) throw ValidationException::withMessages([
|
if (! $request->user()->vouchers()->where('id', '=', $voucher->id)->get()->isEmpty()) {
|
||||||
'code' => __('You already redeemed this voucher code')
|
throw ValidationException::withMessages([
|
||||||
|
'code' => __('You already redeemed this voucher code'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->user()->credits + $voucher->credits >= 99999999) throw ValidationException::withMessages([
|
if ($request->user()->credits + $voucher->credits >= 99999999) {
|
||||||
'code' => "You can't redeem this voucher because you would exceed the limit of " . CREDITS_DISPLAY_NAME
|
throw ValidationException::withMessages([
|
||||||
|
'code' => "You can't redeem this voucher because you would exceed the limit of ".CREDITS_DISPLAY_NAME,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
#redeem voucher
|
//redeem voucher
|
||||||
$voucher->redeem($request->user());
|
$voucher->redeem($request->user());
|
||||||
|
|
||||||
event(new UserUpdateCreditsEvent($request->user()));
|
event(new UserUpdateCreditsEvent($request->user()));
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => "{$voucher->credits} " . CREDITS_DISPLAY_NAME ." ". __("have been added to your balance!")
|
'success' => "{$voucher->credits} ".CREDITS_DISPLAY_NAME.' '.__('have been added to your balance!'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +169,10 @@ class PartnerController extends Controller
|
||||||
|
|
||||||
return datatables($users)
|
return datatables($users)
|
||||||
->editColumn('name', function (User $user) {
|
->editColumn('name', function (User $user) {
|
||||||
return '<a class="text-info" target="_blank" href="' . route('admin.users.show', $user->id) . '">' . $user->name . '</a>';
|
return '<a class="text-info" target="_blank" href="'.route('admin.users.show', $user->id).'">'.$user->name.'</a>';
|
||||||
})
|
})
|
||||||
->addColumn('credits', function (User $user) {
|
->addColumn('credits', function (User $user) {
|
||||||
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
|
return '<i class="fas fa-coins mr-2"></i> '.$user->credits();
|
||||||
})
|
})
|
||||||
->addColumn('last_seen', function (User $user) {
|
->addColumn('last_seen', function (User $user) {
|
||||||
return $user->last_seen ? $user->last_seen->diffForHumans() : '';
|
return $user->last_seen ? $user->last_seen->diffForHumans() : '';
|
||||||
|
@ -170,6 +180,7 @@ class PartnerController extends Controller
|
||||||
->rawColumns(['name', 'credits', 'last_seen'])
|
->rawColumns(['name', 'credits', 'last_seen'])
|
||||||
->make();
|
->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
{
|
{
|
||||||
$query = PartnerDiscount::query();
|
$query = PartnerDiscount::query();
|
||||||
|
@ -177,28 +188,28 @@ class PartnerController extends Controller
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (PartnerDiscount $partner) {
|
->addColumn('actions', function (PartnerDiscount $partner) {
|
||||||
return '
|
return '
|
||||||
<a data-content="'.__("Edit").'" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.partners.edit', $partner->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
<a data-content="'.__('Edit').'" data-toggle="popover" data-trigger="hover" data-placement="top" href="'.route('admin.partners.edit', $partner->id).'" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||||
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.partners.destroy', $partner->id) . '">
|
<form class="d-inline" onsubmit="return submitResult();" method="post" action="'.route('admin.partners.destroy', $partner->id).'">
|
||||||
' . csrf_field() . '
|
'.csrf_field().'
|
||||||
' . method_field("DELETE") . '
|
'.method_field('DELETE').'
|
||||||
<button data-content="'.__("Delete").'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
<button data-content="'.__('Delete').'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
})
|
})
|
||||||
->addColumn('user', function (PartnerDiscount $partner) {
|
->addColumn('user', function (PartnerDiscount $partner) {
|
||||||
return ($user=User::where('id', $partner->user_id)->first())?'<a href="'.route('admin.users.show', $partner->user_id).'">'.$user->name.'</a>':__('Unknown user');
|
return ($user = User::where('id', $partner->user_id)->first()) ? '<a href="'.route('admin.users.show', $partner->user_id).'">'.$user->name.'</a>' : __('Unknown user');
|
||||||
})
|
})
|
||||||
->editColumn('created_at', function (PartnerDiscount $partner) {
|
->editColumn('created_at', function (PartnerDiscount $partner) {
|
||||||
return $partner->created_at ? $partner->created_at->diffForHumans() : '';
|
return $partner->created_at ? $partner->created_at->diffForHumans() : '';
|
||||||
})
|
})
|
||||||
->editColumn('partner_discount', function (PartnerDiscount $partner) {
|
->editColumn('partner_discount', function (PartnerDiscount $partner) {
|
||||||
return $partner->partner_discount ? $partner->partner_discount . "%" : "0%";
|
return $partner->partner_discount ? $partner->partner_discount.'%' : '0%';
|
||||||
})
|
})
|
||||||
->editColumn('registered_user_discount', function (PartnerDiscount $partner) {
|
->editColumn('registered_user_discount', function (PartnerDiscount $partner) {
|
||||||
return $partner->registered_user_discount ? $partner->registered_user_discount . "%" : "0%";
|
return $partner->registered_user_discount ? $partner->registered_user_discount.'%' : '0%';
|
||||||
})
|
})
|
||||||
->editColumn('referral_system_commission', function (PartnerDiscount $partner) {
|
->editColumn('referral_system_commission', function (PartnerDiscount $partner) {
|
||||||
return $partner->referral_system_commission>=0 ? $partner->referral_system_commission . "%" : __('Default') . " (" . config("SETTINGS::REFERRAL:PERCENTAGE") . "%)";
|
return $partner->referral_system_commission >= 0 ? $partner->referral_system_commission.'%' : __('Default').' ('.config('SETTINGS::REFERRAL:PERCENTAGE').'%)';
|
||||||
})
|
})
|
||||||
->rawColumns(['user', 'actions'])
|
->rawColumns(['user', 'actions'])
|
||||||
->make();
|
->make();
|
||||||
|
|
|
@ -16,15 +16,18 @@ class ProductController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @description get product locations based on selected egg
|
* @description get product locations based on selected egg
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Egg $egg
|
* @param Egg $egg
|
||||||
* @return Collection|JsonResponse
|
* @return Collection|JsonResponse
|
||||||
*/
|
*/
|
||||||
public function getNodesBasedOnEgg(Request $request, Egg $egg)
|
public function getNodesBasedOnEgg(Request $request, Egg $egg)
|
||||||
{
|
{
|
||||||
if (is_null($egg->id)) return response()->json('Egg ID is required', '400');
|
if (is_null($egg->id)) {
|
||||||
|
return response()->json('Egg ID is required', '400');
|
||||||
|
}
|
||||||
|
|
||||||
#get products that include this egg
|
//get products that include this egg
|
||||||
$products = Product::query()
|
$products = Product::query()
|
||||||
->with('nodes')
|
->with('nodes')
|
||||||
->where('disabled', '=', false)
|
->where('disabled', '=', false)
|
||||||
|
@ -34,21 +37,21 @@ class ProductController extends Controller
|
||||||
|
|
||||||
$nodes = collect();
|
$nodes = collect();
|
||||||
|
|
||||||
#filter unique nodes
|
//filter unique nodes
|
||||||
$products->each(function (Product $product) use ($nodes) {
|
$products->each(function (Product $product) use ($nodes) {
|
||||||
$product->nodes->each(function (Node $node) use ($nodes) {
|
$product->nodes->each(function (Node $node) use ($nodes) {
|
||||||
if (!$nodes->contains('id', $node->id) && !$node->disabled) {
|
if (! $nodes->contains('id', $node->id) && ! $node->disabled) {
|
||||||
$nodes->add($node);
|
$nodes->add($node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return $nodes;
|
return $nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get product locations based on selected egg
|
* @description get product locations based on selected egg
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Egg $egg
|
* @param Egg $egg
|
||||||
* @return Collection|JsonResponse
|
* @return Collection|JsonResponse
|
||||||
|
@ -56,9 +59,11 @@ class ProductController extends Controller
|
||||||
public function getLocationsBasedOnEgg(Request $request, Egg $egg)
|
public function getLocationsBasedOnEgg(Request $request, Egg $egg)
|
||||||
{
|
{
|
||||||
$nodes = $this->getNodesBasedOnEgg($request, $egg);
|
$nodes = $this->getNodesBasedOnEgg($request, $egg);
|
||||||
foreach($nodes as $key => $node){
|
foreach ($nodes as $key => $node) {
|
||||||
$pteroNode = Pterodactyl::getNode($node->id);
|
$pteroNode = Pterodactyl::getNode($node->id);
|
||||||
if($pteroNode['allocated_resources']['memory']>=($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)||$pteroNode['allocated_resources']['disk']>=($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)) $nodes->forget($key);
|
if ($pteroNode['allocated_resources']['memory'] >= ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100) || $pteroNode['allocated_resources']['disk'] >= ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100)) {
|
||||||
|
$nodes->forget($key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$locations = collect();
|
$locations = collect();
|
||||||
|
|
||||||
|
@ -67,7 +72,7 @@ class ProductController extends Controller
|
||||||
/** @var Location $location */
|
/** @var Location $location */
|
||||||
$location = $node->location;
|
$location = $node->location;
|
||||||
|
|
||||||
if (!$locations->contains('id', $location->id)) {
|
if (! $locations->contains('id', $location->id)) {
|
||||||
$nodeIds = $nodes->map(function ($node) {
|
$nodeIds = $nodes->map(function ($node) {
|
||||||
return $node->id;
|
return $node->id;
|
||||||
});
|
});
|
||||||
|
@ -90,7 +95,9 @@ class ProductController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getProductsBasedOnNode(Egg $egg, Node $node)
|
public function getProductsBasedOnNode(Egg $egg, Node $node)
|
||||||
{
|
{
|
||||||
if (is_null($egg->id) || is_null($node->id)) return response()->json('node and egg id is required', '400');
|
if (is_null($egg->id) || is_null($node->id)) {
|
||||||
|
return response()->json('node and egg id is required', '400');
|
||||||
|
}
|
||||||
|
|
||||||
$products = Product::query()
|
$products = Product::query()
|
||||||
->where('disabled', '=', false)
|
->where('disabled', '=', false)
|
||||||
|
@ -103,8 +110,10 @@ class ProductController extends Controller
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$pteroNode = Pterodactyl::getNode($node->id);
|
$pteroNode = Pterodactyl::getNode($node->id);
|
||||||
foreach($products as $key => $product){
|
foreach ($products as $key => $product) {
|
||||||
if($product->memory>($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)-$pteroNode['allocated_resources']['memory']||$product->disk>($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)-$pteroNode['allocated_resources']['disk']) $product->doesNotFit = true;
|
if ($product->memory > ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['memory'] || $product->disk > ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['disk']) {
|
||||||
|
$product->doesNotFit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $products;
|
return $products;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Pterodactyl;
|
use App\Classes\Pterodactyl;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
@ -30,6 +29,7 @@ class ProfileController extends Controller
|
||||||
$badgeColor = 'badge-secondary';
|
$badgeColor = 'badge-secondary';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('profile.index')->with([
|
return view('profile.index')->with([
|
||||||
'user' => Auth::user(),
|
'user' => Auth::user(),
|
||||||
'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'),
|
'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'),
|
||||||
|
@ -39,16 +39,14 @@ class ProfileController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function selfDestroyUser()
|
||||||
|
{
|
||||||
public function selfDestroyUser(){
|
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
//if ($user->role == "admin") return back()->with("error", "You cannot delete yourself as an admin!");
|
//if ($user->role == "admin") return back()->with("error", "You cannot delete yourself as an admin!");
|
||||||
|
|
||||||
$user->delete();
|
$user->delete();
|
||||||
return redirect("/login")->with('success', __("Account permanently deleted!"));
|
|
||||||
|
|
||||||
|
return redirect('/login')->with('success', __('Account permanently deleted!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update the specified resource in storage.
|
/** Update the specified resource in storage.
|
||||||
|
@ -59,60 +57,63 @@ class ProfileController extends Controller
|
||||||
public function update(Request $request, int $id)
|
public function update(Request $request, int $id)
|
||||||
{
|
{
|
||||||
//prevent other users from editing a user
|
//prevent other users from editing a user
|
||||||
if ($id != Auth::user()->id) dd(401);
|
if ($id != Auth::user()->id) {
|
||||||
|
dd(401);
|
||||||
|
}
|
||||||
$user = User::findOrFail($id);
|
$user = User::findOrFail($id);
|
||||||
|
|
||||||
//update password if necessary
|
//update password if necessary
|
||||||
if (!is_null($request->input('new_password'))) {
|
if (! is_null($request->input('new_password'))) {
|
||||||
|
|
||||||
//validate password request
|
//validate password request
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'current_password' => [
|
'current_password' => [
|
||||||
'required',
|
'required',
|
||||||
function ($attribute, $value, $fail) use ($user) {
|
function ($attribute, $value, $fail) use ($user) {
|
||||||
if (!Hash::check($value, $user->password)) {
|
if (! Hash::check($value, $user->password)) {
|
||||||
$fail('The ' . $attribute . ' is invalid.');
|
$fail('The '.$attribute.' is invalid.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'new_password' => 'required|string|min:8',
|
'new_password' => 'required|string|min:8',
|
||||||
'new_password_confirmation' => 'required|same:new_password'
|
'new_password_confirmation' => 'required|same:new_password',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Update Users Password on Pterodactyl
|
//Update Users Password on Pterodactyl
|
||||||
//Username,Mail,First and Lastname are required aswell
|
//Username,Mail,First and Lastname are required aswell
|
||||||
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
||||||
"password" => $request->input('new_password'),
|
'password' => $request->input('new_password'),
|
||||||
"username" => $request->input('name'),
|
'username' => $request->input('name'),
|
||||||
"first_name" => $request->input('name'),
|
'first_name' => $request->input('name'),
|
||||||
"last_name" => $request->input('name'),
|
'last_name' => $request->input('name'),
|
||||||
"email" => $request->input('email'),
|
'email' => $request->input('email'),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
||||||
'pterodactyl_error_status' => $response->toException()->getCode()
|
'pterodactyl_error_status' => $response->toException()->getCode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
//update password
|
//update password
|
||||||
$user->update([
|
$user->update([
|
||||||
'password' => Hash::make($request->input('new_password')),
|
'password' => Hash::make($request->input('new_password')),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate request
|
//validate request
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'name' => 'required|min:4|max:30|alpha_num|unique:users,name,' . $id . ',id',
|
'name' => 'required|min:4|max:30|alpha_num|unique:users,name,'.$id.',id',
|
||||||
'email' => 'required|email|max:64|unique:users,email,' . $id . ',id',
|
'email' => 'required|email|max:64|unique:users,email,'.$id.',id',
|
||||||
'avatar' => 'nullable'
|
'avatar' => 'nullable',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//update avatar
|
//update avatar
|
||||||
if (!is_null($request->input('avatar'))) {
|
if (! is_null($request->input('avatar'))) {
|
||||||
$avatar = json_decode($request->input('avatar'));
|
$avatar = json_decode($request->input('avatar'));
|
||||||
if ($avatar->input->size > 3000000) abort(500);
|
if ($avatar->input->size > 3000000) {
|
||||||
|
abort(500);
|
||||||
|
}
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'avatar' => $avatar->output->image,
|
'avatar' => $avatar->output->image,
|
||||||
|
@ -125,16 +126,16 @@ class ProfileController extends Controller
|
||||||
|
|
||||||
//update name and email on Pterodactyl
|
//update name and email on Pterodactyl
|
||||||
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
$response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
||||||
"username" => $request->input('name'),
|
'username' => $request->input('name'),
|
||||||
"first_name" => $request->input('name'),
|
'first_name' => $request->input('name'),
|
||||||
"last_name" => $request->input('name'),
|
'last_name' => $request->input('name'),
|
||||||
"email" => $request->input('email'),
|
'email' => $request->input('email'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
'pterodactyl_error_message' => $response->toException()->getMessage(),
|
||||||
'pterodactyl_error_status' => $response->toException()->getCode()
|
'pterodactyl_error_status' => $response->toException()->getCode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ class ProfileController extends Controller
|
||||||
if ($request->input('email') != Auth::user()->email) {
|
if ($request->input('email') != Auth::user()->email) {
|
||||||
$user->reVerifyEmail();
|
$user->reVerifyEmail();
|
||||||
$user->sendEmailVerificationNotification();
|
$user->sendEmailVerificationNotification();
|
||||||
};
|
}
|
||||||
|
|
||||||
return redirect()->route('profile.index')->with('success', __('Profile updated'));
|
return redirect()->route('profile.index')->with('success', __('Profile updated'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ class ServerController extends Controller
|
||||||
|
|
||||||
//Get server infos from ptero
|
//Get server infos from ptero
|
||||||
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id, true);
|
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id, true);
|
||||||
if(!$serverAttributes) continue;
|
if (! $serverAttributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$serverRelationships = $serverAttributes['relationships'];
|
$serverRelationships = $serverAttributes['relationships'];
|
||||||
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ class ServerController extends Controller
|
||||||
|
|
||||||
//Check if a server got renamed on Pterodactyl
|
//Check if a server got renamed on Pterodactyl
|
||||||
$savedServer = Server::query()->where('id', $server->id)->first();
|
$savedServer = Server::query()->where('id', $server->id)->first();
|
||||||
if($savedServer->name != $serverAttributes['name']){
|
if ($savedServer->name != $serverAttributes['name']) {
|
||||||
$savedServer->name = $serverAttributes['name'];
|
$savedServer->name = $serverAttributes['name'];
|
||||||
$server->name = $serverAttributes['name'];
|
$server->name = $serverAttributes['name'];
|
||||||
$savedServer->save();
|
$savedServer->save();
|
||||||
|
@ -59,14 +61,16 @@ class ServerController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('servers.index')->with([
|
return view('servers.index')->with([
|
||||||
'servers' => $servers
|
'servers' => $servers,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show the form for creating a new resource. */
|
/** Show the form for creating a new resource. */
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
if (!is_null($this->validateConfigurationRules())) return $this->validateConfigurationRules();
|
if (! is_null($this->validateConfigurationRules())) {
|
||||||
|
return $this->validateConfigurationRules();
|
||||||
|
}
|
||||||
|
|
||||||
$productCount = Product::query()->where('disabled', '=', false)->count();
|
$productCount = Product::query()->where('disabled', '=', false)->count();
|
||||||
$locations = Location::all();
|
$locations = Location::all();
|
||||||
|
@ -109,8 +113,8 @@ class ServerController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// minimum credits && Check for Allocation
|
// minimum credits && Check for Allocation
|
||||||
if (FacadesRequest::has("product")) {
|
if (FacadesRequest::has('product')) {
|
||||||
$product = Product::findOrFail(FacadesRequest::input("product"));
|
$product = Product::findOrFail(FacadesRequest::input('product'));
|
||||||
|
|
||||||
// Get node resource allocation info
|
// Get node resource allocation info
|
||||||
$node = $product->nodes()->findOrFail(FacadesRequest::input('node'));
|
$node = $product->nodes()->findOrFail(FacadesRequest::input('node'));
|
||||||
|
@ -118,7 +122,9 @@ class ServerController extends Controller
|
||||||
|
|
||||||
// Check if node has enough memory and disk space
|
// Check if node has enough memory and disk space
|
||||||
$checkResponse = Pterodactyl::checkNodeResources($node, $product->memory, $product->disk);
|
$checkResponse = Pterodactyl::checkNodeResources($node, $product->memory, $product->disk);
|
||||||
if ($checkResponse == False) return redirect()->route('servers.index')->with('error', __("The node '" . $nodeName . "' doesn't have the required memory or disk left to allocate this product."));
|
if ($checkResponse == false) {
|
||||||
|
return redirect()->route('servers.index')->with('error', __("The node '".$nodeName."' doesn't have the required memory or disk left to allocate this product."));
|
||||||
|
}
|
||||||
|
|
||||||
// Min. Credits
|
// Min. Credits
|
||||||
if (
|
if (
|
||||||
|
@ -127,24 +133,24 @@ class ServerController extends Controller
|
||||||
? config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
|
? config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
|
||||||
: $product->minimum_credits)
|
: $product->minimum_credits)
|
||||||
) {
|
) {
|
||||||
return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to use this product!");
|
return redirect()->route('servers.index')->with('error', 'You do not have the required amount of '.CREDITS_DISPLAY_NAME.' to use this product!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', 'false') === 'true' && !Auth::user()->hasVerifiedEmail()) {
|
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', 'false') === 'true' && ! Auth::user()->hasVerifiedEmail()) {
|
||||||
return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can create a server."));
|
return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can create a server.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
|
|
||||||
if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', 'true') && Auth::user()->role != "admin") {
|
if (! config('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', 'true') && Auth::user()->role != 'admin') {
|
||||||
return redirect()->route('servers.index')->with('error', __("The system administrator has blocked the creation of new servers."));
|
return redirect()->route('servers.index')->with('error', __('The system administrator has blocked the creation of new servers.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
if (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', 'false') === 'true' && !Auth::user()->discordUser) {
|
if (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', 'false') === 'true' && ! Auth::user()->discordUser) {
|
||||||
return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can create a server."));
|
return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can create a server.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -156,14 +162,15 @@ class ServerController extends Controller
|
||||||
/** @var Node $node */
|
/** @var Node $node */
|
||||||
/** @var Egg $egg */
|
/** @var Egg $egg */
|
||||||
/** @var Product $product */
|
/** @var Product $product */
|
||||||
|
if (! is_null($this->validateConfigurationRules())) {
|
||||||
if (!is_null($this->validateConfigurationRules())) return $this->validateConfigurationRules();
|
return $this->validateConfigurationRules();
|
||||||
|
}
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"name" => "required|max:191",
|
'name' => 'required|max:191',
|
||||||
"node" => "required|exists:nodes,id",
|
'node' => 'required|exists:nodes,id',
|
||||||
"egg" => "required|exists:eggs,id",
|
'egg' => 'required|exists:eggs,id',
|
||||||
"product" => "required|exists:products,id"
|
'product' => 'required|exists:products,id',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//get required resources
|
//get required resources
|
||||||
|
@ -178,17 +185,21 @@ class ServerController extends Controller
|
||||||
|
|
||||||
//get free allocation ID
|
//get free allocation ID
|
||||||
$allocationId = Pterodactyl::getFreeAllocationId($node);
|
$allocationId = Pterodactyl::getFreeAllocationId($node);
|
||||||
if (!$allocationId) return $this->noAllocationsError($server);
|
if (! $allocationId) {
|
||||||
|
return $this->noAllocationsError($server);
|
||||||
|
}
|
||||||
|
|
||||||
//create server on pterodactyl
|
//create server on pterodactyl
|
||||||
$response = Pterodactyl::createServer($server, $egg, $allocationId);
|
$response = Pterodactyl::createServer($server, $egg, $allocationId);
|
||||||
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
if ($response->failed()) {
|
||||||
|
return $this->serverCreationFailed($response, $server);
|
||||||
|
}
|
||||||
|
|
||||||
$serverAttributes = $response->json()['attributes'];
|
$serverAttributes = $response->json()['attributes'];
|
||||||
//update server with pterodactyl_id
|
//update server with pterodactyl_id
|
||||||
$server->update([
|
$server->update([
|
||||||
'pterodactyl_id' => $serverAttributes['id'],
|
'pterodactyl_id' => $serverAttributes['id'],
|
||||||
'identifier' => $serverAttributes['identifier']
|
'identifier' => $serverAttributes['identifier'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (config('SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') {
|
if (config('SETTINGS::SYSTEM:SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') {
|
||||||
|
@ -202,6 +213,7 @@ class ServerController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return redirect with error
|
* return redirect with error
|
||||||
|
*
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
|
@ -210,11 +222,13 @@ class ServerController extends Controller
|
||||||
$server->delete();
|
$server->delete();
|
||||||
|
|
||||||
Auth::user()->notify(new ServerCreationError($server));
|
Auth::user()->notify(new ServerCreationError($server));
|
||||||
|
|
||||||
return redirect()->route('servers.index')->with('error', __('No allocations satisfying the requirements for automatic deployment on this node were found.'));
|
return redirect()->route('servers.index')->with('error', __('No allocations satisfying the requirements for automatic deployment on this node were found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return redirect with error
|
* return redirect with error
|
||||||
|
*
|
||||||
* @param Response $response
|
* @param Response $response
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
|
@ -231,18 +245,19 @@ class ServerController extends Controller
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$server->delete();
|
$server->delete();
|
||||||
|
|
||||||
return redirect()->route('servers.index')->with('success', __('Server removed'));
|
return redirect()->route('servers.index')->with('success', __('Server removed'));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return redirect()->route('servers.index')->with('error', __('An exception has occurred while trying to remove a resource "') . $e->getMessage() . '"');
|
return redirect()->route('servers.index')->with('error', __('An exception has occurred while trying to remove a resource "').$e->getMessage().'"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show Server Settings */
|
/** Show Server Settings */
|
||||||
public function show(Server $server)
|
public function show(Server $server)
|
||||||
{
|
{
|
||||||
|
if ($server->user_id != Auth::user()->id) {
|
||||||
|
return back()->with('error', __('´This is not your Server!'));
|
||||||
if($server->user_id != Auth::user()->id){ return back()->with('error', __('´This is not your Server!'));}
|
}
|
||||||
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id);
|
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id);
|
||||||
$serverRelationships = $serverAttributes['relationships'];
|
$serverRelationships = $serverAttributes['relationships'];
|
||||||
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
||||||
|
@ -261,7 +276,7 @@ class ServerController extends Controller
|
||||||
|
|
||||||
$pteroNode = Pterodactyl::getNode($serverRelationships['node']['attributes']['id']);
|
$pteroNode = Pterodactyl::getNode($serverRelationships['node']['attributes']['id']);
|
||||||
|
|
||||||
$products = Product::orderBy("created_at")
|
$products = Product::orderBy('created_at')
|
||||||
->whereHas('nodes', function (Builder $builder) use ($serverRelationships) { //Only show products for that node
|
->whereHas('nodes', function (Builder $builder) use ($serverRelationships) { //Only show products for that node
|
||||||
$builder->where('id', '=', $serverRelationships['node']['attributes']['id']);
|
$builder->where('id', '=', $serverRelationships['node']['attributes']['id']);
|
||||||
})
|
})
|
||||||
|
@ -270,20 +285,23 @@ class ServerController extends Controller
|
||||||
// Set the each product eggs array to just contain the eggs name
|
// Set the each product eggs array to just contain the eggs name
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$product->eggs = $product->eggs->pluck('name')->toArray();
|
$product->eggs = $product->eggs->pluck('name')->toArray();
|
||||||
if($product->memory-$currentProduct->memory>($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)-$pteroNode['allocated_resources']['memory']||$product->disk-$currentProduct->disk>($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)-$pteroNode['allocated_resources']['disk']) $product->doesNotFit = true;
|
if ($product->memory - $currentProduct->memory > ($pteroNode['memory'] * ($pteroNode['memory_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['memory'] || $product->disk - $currentProduct->disk > ($pteroNode['disk'] * ($pteroNode['disk_overallocate'] + 100) / 100) - $pteroNode['allocated_resources']['disk']) {
|
||||||
|
$product->doesNotFit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('servers.settings')->with([
|
return view('servers.settings')->with([
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'products' => $products
|
'products' => $products,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function upgrade(Server $server, Request $request)
|
public function upgrade(Server $server, Request $request)
|
||||||
{
|
{
|
||||||
if($server->user_id != Auth::user()->id) return redirect()->route('servers.index');
|
if ($server->user_id != Auth::user()->id) {
|
||||||
if(!isset($request->product_upgrade))
|
return redirect()->route('servers.index');
|
||||||
{
|
}
|
||||||
|
if (! isset($request->product_upgrade)) {
|
||||||
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('this product is the only one'));
|
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('this product is the only one'));
|
||||||
}
|
}
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
@ -301,30 +319,33 @@ class ServerController extends Controller
|
||||||
$requireMemory = $newProduct->memory - $oldProduct->memory;
|
$requireMemory = $newProduct->memory - $oldProduct->memory;
|
||||||
$requiredisk = $newProduct->disk - $oldProduct->disk;
|
$requiredisk = $newProduct->disk - $oldProduct->disk;
|
||||||
$checkResponse = Pterodactyl::checkNodeResources($node, $requireMemory, $requiredisk);
|
$checkResponse = Pterodactyl::checkNodeResources($node, $requireMemory, $requiredisk);
|
||||||
if ($checkResponse == False) return redirect()->route('servers.index')->with('error', __("The node '" . $nodeName . "' doesn't have the required memory or disk left to upgrade the server."));
|
if ($checkResponse == false) {
|
||||||
|
return redirect()->route('servers.index')->with('error', __("The node '".$nodeName."' doesn't have the required memory or disk left to upgrade the server."));
|
||||||
|
}
|
||||||
|
|
||||||
$priceupgrade = $newProduct->getHourlyPrice();
|
$priceupgrade = $newProduct->getHourlyPrice();
|
||||||
|
|
||||||
if ($priceupgrade < $oldProduct->getHourlyPrice()) {
|
if ($priceupgrade < $oldProduct->getHourlyPrice()) {
|
||||||
$priceupgrade = 0;
|
$priceupgrade = 0;
|
||||||
}
|
}
|
||||||
if ($user->credits >= $priceupgrade && $user->credits >= $newProduct->minimum_credits)
|
if ($user->credits >= $priceupgrade && $user->credits >= $newProduct->minimum_credits) {
|
||||||
{
|
|
||||||
|
|
||||||
$server->product_id = $request->product_upgrade;
|
$server->product_id = $request->product_upgrade;
|
||||||
$server->update();
|
$server->update();
|
||||||
$server->allocation = $serverAttributes['allocation'];
|
$server->allocation = $serverAttributes['allocation'];
|
||||||
$response = Pterodactyl::updateServer($server, $newProduct);
|
$response = Pterodactyl::updateServer($server, $newProduct);
|
||||||
if ($response->failed()) return $this->serverCreationFailed($response, $server);
|
if ($response->failed()) {
|
||||||
|
return $this->serverCreationFailed($response, $server);
|
||||||
|
}
|
||||||
//update user balance
|
//update user balance
|
||||||
$user->decrement('credits', $priceupgrade);
|
$user->decrement('credits', $priceupgrade);
|
||||||
//restart the server
|
//restart the server
|
||||||
$response = Pterodactyl::powerAction($server, "restart");
|
$response = Pterodactyl::powerAction($server, 'restart');
|
||||||
if ($response->failed()) return redirect()->route('servers.index')->with('error', $response->json()['errors'][0]['detail']);
|
if ($response->failed()) {
|
||||||
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
|
return redirect()->route('servers.index')->with('error', $response->json()['errors'][0]['detail']);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
|
||||||
|
} else {
|
||||||
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));
|
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\ShopProduct;
|
use App\Models\ShopProduct;
|
||||||
use App\Models\Settings;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class StoreController extends Controller
|
class StoreController extends Controller
|
||||||
|
@ -15,18 +14,20 @@ class StoreController extends Controller
|
||||||
|
|
||||||
if (
|
if (
|
||||||
env('APP_ENV') == 'local' ||
|
env('APP_ENV') == 'local' ||
|
||||||
config("SETTINGS::PAYMENTS:PAYPAL:SECRET") && config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") ||
|
config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
|
||||||
config("SETTINGS::PAYMENTS:STRIPE:SECRET") && config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && config("SETTINGS::PAYMENTS:STRIPE:METHODS")
|
config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
|
||||||
) $isPaymentSetup = true;
|
) {
|
||||||
|
$isPaymentSetup = true;
|
||||||
//Required Verification for creating an server
|
|
||||||
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
|
|
||||||
return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
if (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
|
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && ! Auth::user()->hasVerifiedEmail()) {
|
||||||
return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits"));
|
return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can purchase credits.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Required Verification for creating an server
|
||||||
|
if (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && ! Auth::user()->discordUser) {
|
||||||
|
return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('store.index')->with([
|
return view('store.index')->with([
|
||||||
|
|
|
@ -2,58 +2,60 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\Facades\Notification;
|
|
||||||
|
|
||||||
use App\Models\Ticket;
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\TicketComment;
|
use App\Models\Ticket;
|
||||||
use App\Models\TicketCategory;
|
|
||||||
use App\Models\TicketBlacklist;
|
use App\Models\TicketBlacklist;
|
||||||
use App\Notifications\Ticket\User\CreateNotification;
|
use App\Models\TicketCategory;
|
||||||
|
use App\Models\TicketComment;
|
||||||
|
use App\Models\User;
|
||||||
use App\Notifications\Ticket\Admin\AdminCreateNotification;
|
use App\Notifications\Ticket\Admin\AdminCreateNotification;
|
||||||
use App\Notifications\Ticket\Admin\AdminReplyNotification;
|
use App\Notifications\Ticket\Admin\AdminReplyNotification;
|
||||||
|
use App\Notifications\Ticket\User\CreateNotification;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class TicketsController extends Controller
|
class TicketsController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$tickets = Ticket::where("user_id", Auth::user()->id)->paginate(10);
|
$tickets = Ticket::where('user_id', Auth::user()->id)->paginate(10);
|
||||||
$ticketcategories = TicketCategory::all();
|
$ticketcategories = TicketCategory::all();
|
||||||
|
|
||||||
return view("ticket.index", compact("tickets", "ticketcategories"));
|
return view('ticket.index', compact('tickets', 'ticketcategories'));
|
||||||
}
|
}
|
||||||
public function create() {
|
|
||||||
#check in blacklist
|
public function create()
|
||||||
|
{
|
||||||
|
//check in blacklist
|
||||||
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
|
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
|
||||||
if($check && $check->status == "True"){
|
if ($check && $check->status == 'True') {
|
||||||
return redirect()->route('ticket.index')->with('error', __("You can't make a ticket because you're on the blacklist for a reason: '" . $check->reason . "', please contact the administrator"));
|
return redirect()->route('ticket.index')->with('error', __("You can't make a ticket because you're on the blacklist for a reason: '".$check->reason."', please contact the administrator"));
|
||||||
}
|
}
|
||||||
$ticketcategories = TicketCategory::all();
|
$ticketcategories = TicketCategory::all();
|
||||||
$servers = Auth::user()->servers;
|
$servers = Auth::user()->servers;
|
||||||
return view("ticket.create", compact("ticketcategories", "servers"));
|
|
||||||
|
return view('ticket.create', compact('ticketcategories', 'servers'));
|
||||||
}
|
}
|
||||||
public function store(Request $request) {
|
|
||||||
$this->validate($request, array(
|
public function store(Request $request)
|
||||||
"title" => "required",
|
{
|
||||||
"ticketcategory" => "required",
|
$this->validate($request, [
|
||||||
"priority" => "required",
|
'title' => 'required',
|
||||||
"message" => "required")
|
'ticketcategory' => 'required',
|
||||||
|
'priority' => 'required',
|
||||||
|
'message' => 'required', ]
|
||||||
);
|
);
|
||||||
$ticket = new Ticket(array(
|
$ticket = new Ticket([
|
||||||
"title" => $request->input("title"),
|
'title' => $request->input('title'),
|
||||||
"user_id" => Auth::user()->id,
|
'user_id' => Auth::user()->id,
|
||||||
"ticket_id" => strtoupper(Str::random(5)),
|
'ticket_id' => strtoupper(Str::random(5)),
|
||||||
"ticketcategory_id" => $request->input("ticketcategory"),
|
'ticketcategory_id' => $request->input('ticketcategory'),
|
||||||
"priority" => $request->input("priority"),
|
'priority' => $request->input('priority'),
|
||||||
"message" => $request->input("message"),
|
'message' => $request->input('message'),
|
||||||
"status" => "Open",
|
'status' => 'Open',
|
||||||
"server" => $request->input("server"))
|
'server' => $request->input('server'), ]
|
||||||
);
|
);
|
||||||
$ticket->save();
|
$ticket->save();
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
@ -61,35 +63,41 @@ class TicketsController extends Controller
|
||||||
$user->notify(new CreateNotification($ticket));
|
$user->notify(new CreateNotification($ticket));
|
||||||
Notification::send($admin, new AdminCreateNotification($ticket, $user));
|
Notification::send($admin, new AdminCreateNotification($ticket, $user));
|
||||||
|
|
||||||
return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #') . $ticket->ticket_id);
|
return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #').$ticket->ticket_id);
|
||||||
}
|
}
|
||||||
public function show($ticket_id) {
|
|
||||||
$ticket = Ticket::where("ticket_id", $ticket_id)->firstOrFail();
|
public function show($ticket_id)
|
||||||
|
{
|
||||||
|
$ticket = Ticket::where('ticket_id', $ticket_id)->firstOrFail();
|
||||||
$ticketcomments = $ticket->ticketcomments;
|
$ticketcomments = $ticket->ticketcomments;
|
||||||
$ticketcategory = $ticket->ticketcategory;
|
$ticketcategory = $ticket->ticketcategory;
|
||||||
$server = Server::where('id', $ticket->server)->first();
|
$server = Server::where('id', $ticket->server)->first();
|
||||||
return view("ticket.show", compact("ticket", "ticketcategory", "ticketcomments", "server"));
|
|
||||||
|
return view('ticket.show', compact('ticket', 'ticketcategory', 'ticketcomments', 'server'));
|
||||||
}
|
}
|
||||||
public function reply(Request $request) {
|
|
||||||
#check in blacklist
|
public function reply(Request $request)
|
||||||
|
{
|
||||||
|
//check in blacklist
|
||||||
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
|
$check = TicketBlacklist::where('user_id', Auth::user()->id)->first();
|
||||||
if($check && $check->status == "True"){
|
if ($check && $check->status == 'True') {
|
||||||
return redirect()->route('ticket.index')->with('error', __("You can't reply a ticket because you're on the blacklist for a reason: '" . $check->reason . "', please contact the administrator"));
|
return redirect()->route('ticket.index')->with('error', __("You can't reply a ticket because you're on the blacklist for a reason: '".$check->reason."', please contact the administrator"));
|
||||||
}
|
}
|
||||||
$this->validate($request, array("ticketcomment" => "required"));
|
$this->validate($request, ['ticketcomment' => 'required']);
|
||||||
$ticket = Ticket::where('id', $request->input("ticket_id"))->firstOrFail();
|
$ticket = Ticket::where('id', $request->input('ticket_id'))->firstOrFail();
|
||||||
$ticket->status = "Client Reply";
|
$ticket->status = 'Client Reply';
|
||||||
$ticket->update();
|
$ticket->update();
|
||||||
$ticketcomment = TicketComment::create(array(
|
$ticketcomment = TicketComment::create([
|
||||||
"ticket_id" => $request->input("ticket_id"),
|
'ticket_id' => $request->input('ticket_id'),
|
||||||
"user_id" => Auth::user()->id,
|
'user_id' => Auth::user()->id,
|
||||||
"ticketcomment" => $request->input("ticketcomment"),
|
'ticketcomment' => $request->input('ticketcomment'),
|
||||||
"message" => $request->input("message")
|
'message' => $request->input('message'),
|
||||||
));
|
]);
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
|
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
|
||||||
$newmessage = $request->input("ticketcomment");
|
$newmessage = $request->input('ticketcomment');
|
||||||
Notification::send($admin, new AdminReplyNotification($ticket, $user, $newmessage));
|
Notification::send($admin, new AdminReplyNotification($ticket, $user, $newmessage));
|
||||||
|
|
||||||
return redirect()->back()->with('success', __('Your comment has been submitted'));
|
return redirect()->back()->with('success', __('Your comment has been submitted'));
|
||||||
}
|
}
|
||||||
public function close($ticket_id)
|
public function close($ticket_id)
|
||||||
|
@ -102,14 +110,14 @@ class TicketsController extends Controller
|
||||||
|
|
||||||
public function dataTable()
|
public function dataTable()
|
||||||
{
|
{
|
||||||
$query = Ticket::where("user_id", Auth::user()->id)->get();
|
$query = Ticket::where('user_id', Auth::user()->id)->get();
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('category', function (Ticket $tickets) {
|
->addColumn('category', function (Ticket $tickets) {
|
||||||
return $tickets->ticketcategory->name;
|
return $tickets->ticketcategory->name;
|
||||||
})
|
})
|
||||||
->editColumn('title', function (Ticket $tickets) {
|
->editColumn('title', function (Ticket $tickets) {
|
||||||
return '<a class="text-info" href="' . route('ticket.show', ['ticket_id' => $tickets->ticket_id]) . '">' . "#" . $tickets->ticket_id . " - " . $tickets->title . '</a>';
|
return '<a class="text-info" href="'.route('ticket.show', ['ticket_id' => $tickets->ticket_id]).'">'.'#'.$tickets->ticket_id.' - '.$tickets->title.'</a>';
|
||||||
})
|
})
|
||||||
->editColumn('status', function (Ticket $tickets) {
|
->editColumn('status', function (Ticket $tickets) {
|
||||||
switch ($tickets->status) {
|
switch ($tickets->status) {
|
||||||
|
@ -127,7 +135,7 @@ class TicketsController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="badge ' . $badgeColor . '">' . $tickets->status . '</span>';
|
return '<span class="badge '.$badgeColor.'">'.$tickets->status.'</span>';
|
||||||
})
|
})
|
||||||
->editColumn('priority', function (Ticket $tickets) {
|
->editColumn('priority', function (Ticket $tickets) {
|
||||||
return __($tickets->priority);
|
return __($tickets->priority);
|
||||||
|
|
|
@ -8,16 +8,15 @@ use Illuminate\Support\Facades\Session;
|
||||||
class TranslationController extends Controller
|
class TranslationController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Change session locale
|
* Change session locale
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function changeLocale(Request $request)
|
public function changeLocale(Request $request)
|
||||||
{
|
{
|
||||||
Session::put('locale', $request->inputLocale);
|
Session::put('locale', $request->inputLocale);
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Kernel extends HttpKernel
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
// \App\Http\Middleware\TrustHosts::class,
|
// \App\Http\Middleware\TrustHosts::class,
|
||||||
\App\Http\Middleware\TrustProxies::class,
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
\Fruitcake\Cors\HandleCors::class,
|
\Illuminate\Http\Middleware\HandleCors::class,
|
||||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
\App\Http\Middleware\TrimStrings::class,
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
@ -39,7 +39,6 @@ class Kernel extends HttpKernel
|
||||||
\App\Http\Middleware\EncryptCookies::class,
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
\Illuminate\Session\Middleware\StartSession::class,
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
|
||||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
@ -51,7 +50,7 @@ class Kernel extends HttpKernel
|
||||||
'api' => [
|
'api' => [
|
||||||
'throttle:api',
|
'throttle:api',
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
GlobalNames::class
|
GlobalNames::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -65,6 +64,7 @@ class Kernel extends HttpKernel
|
||||||
protected $routeMiddleware = [
|
protected $routeMiddleware = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
@ -75,6 +75,6 @@ class Kernel extends HttpKernel
|
||||||
'admin' => isAdmin::class,
|
'admin' => isAdmin::class,
|
||||||
'moderator' => isMod::class,
|
'moderator' => isMod::class,
|
||||||
'api.token' => ApiAuthToken::class,
|
'api.token' => ApiAuthToken::class,
|
||||||
'checkSuspended' => CheckSuspended::class
|
'checkSuspended' => CheckSuspended::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,17 @@ class ApiAuthToken
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if (empty($request->bearerToken())) return response()->json(['message' => 'Missing Authorization header'], 403);
|
if (empty($request->bearerToken())) {
|
||||||
|
return response()->json(['message' => 'Missing Authorization header'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
$token = ApplicationApi::find($request->bearerToken());
|
$token = ApplicationApi::find($request->bearerToken());
|
||||||
if (is_null($token)) return response()->json(['message' => 'Invalid Authorization token'], 401);
|
if (is_null($token)) {
|
||||||
|
return response()->json(['message' => 'Invalid Authorization token'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
$token->updateLastUsed();
|
$token->updateLastUsed();
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ class CheckSuspended
|
||||||
|
|
||||||
return redirect()->route('login')->withMessage($message);
|
return redirect()->route('login')->withMessage($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use App\Models\Configuration;
|
|
||||||
use App\Models\Settings;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
@ -20,7 +18,7 @@ class GlobalNames
|
||||||
{
|
{
|
||||||
define('CREDITS_DISPLAY_NAME', config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', 'Credits'));
|
define('CREDITS_DISPLAY_NAME', config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', 'Credits'));
|
||||||
|
|
||||||
$unsupported_lang_array = explode(',', config("app.unsupported_locales"));
|
$unsupported_lang_array = explode(',', config('app.unsupported_locales'));
|
||||||
$unsupported_lang_array = array_map('strtolower', $unsupported_lang_array);
|
$unsupported_lang_array = array_map('strtolower', $unsupported_lang_array);
|
||||||
define('UNSUPPORTED_LANGS', $unsupported_lang_array);
|
define('UNSUPPORTED_LANGS', $unsupported_lang_array);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use DateTime;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
@ -18,11 +17,11 @@ class LastSeen
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if (env('APP_ENV' , 'local') == 'local'){
|
if (env('APP_ENV', 'local') == 'local') {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Auth::check()) {
|
if (! Auth::check()) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ class LastSeen
|
||||||
|
|
||||||
Auth::user()->update([
|
Auth::user()->update([
|
||||||
'last_seen' => now(),
|
'last_seen' => now(),
|
||||||
'ip' => $request->ip()
|
'ip' => $request->ip(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use App\Models\Settings;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
@ -10,9 +9,7 @@ use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
class SetLocale
|
class SetLocale
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
@ -22,15 +19,15 @@ class SetLocale
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if (Session::has('locale')) {
|
if (Session::has('locale')) {
|
||||||
$locale = Session::get('locale', config("SETTINGS::LOCALE:DEFAULT"));
|
$locale = Session::get('locale', config('SETTINGS::LOCALE:DEFAULT'));
|
||||||
} else {
|
} else {
|
||||||
if (config("SETTINGS::LOCALE:DYNAMIC") !== "true") {
|
if (config('SETTINGS::LOCALE:DYNAMIC') !== 'true') {
|
||||||
$locale = config("SETTINGS::LOCALE:DEFAULT");
|
$locale = config('SETTINGS::LOCALE:DEFAULT');
|
||||||
} else {
|
} else {
|
||||||
$locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
|
$locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
|
||||||
|
|
||||||
if (!in_array($locale, explode(',', config("SETTINGS::LOCALE:AVAILABLE")))) {
|
if (! in_array($locale, explode(',', config('SETTINGS::LOCALE:AVAILABLE')))) {
|
||||||
$locale = config("SETTINGS::LOCALE:DEFAULT");
|
$locale = config('SETTINGS::LOCALE:DEFAULT');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,10 @@ class TrimStrings extends Middleware
|
||||||
/**
|
/**
|
||||||
* The names of the attributes that should not be trimmed.
|
* The names of the attributes that should not be trimmed.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
|
'current_password',
|
||||||
'password',
|
'password',
|
||||||
'password_confirmation',
|
'password_confirmation',
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class TrustProxies extends Middleware
|
class TrustProxies extends Middleware
|
||||||
|
@ -10,7 +10,7 @@ class TrustProxies extends Middleware
|
||||||
/**
|
/**
|
||||||
* The trusted proxies for this application.
|
* The trusted proxies for this application.
|
||||||
*
|
*
|
||||||
* @var array|string|null
|
* @var array<int, string>|string|null
|
||||||
*/
|
*/
|
||||||
protected $proxies;
|
protected $proxies;
|
||||||
|
|
||||||
|
@ -19,5 +19,10 @@ class TrustProxies extends Middleware
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
}
|
}
|
||||||
|
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||||
|
|
||||||
|
class ValidateSignature extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the query string parameters that should be ignored.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
// 'fbclid',
|
||||||
|
// 'utm_campaign',
|
||||||
|
// 'utm_content',
|
||||||
|
// 'utm_medium',
|
||||||
|
// 'utm_source',
|
||||||
|
// 'utm_term',
|
||||||
|
];
|
||||||
|
}
|
|
@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
'payment/StripeWebhooks'
|
'payment/StripeWebhooks',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Settings;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
@ -15,6 +14,7 @@ class UnsuspendServers implements ShouldQueue
|
||||||
*
|
*
|
||||||
* @param UserUpdateCreditsEvent $event
|
* @param UserUpdateCreditsEvent $event
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function handle(UserUpdateCreditsEvent $event)
|
public function handle(UserUpdateCreditsEvent $event)
|
||||||
|
@ -22,7 +22,9 @@ class UnsuspendServers implements ShouldQueue
|
||||||
if ($event->user->credits > config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
|
if ($event->user->credits > config('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
|
||||||
/** @var Server $server */
|
/** @var Server $server */
|
||||||
foreach ($event->user->servers as $server) {
|
foreach ($event->user->servers as $server) {
|
||||||
if ($server->isSuspended()) $server->unSuspend();
|
if ($server->isSuspended()) {
|
||||||
|
$server->unSuspend();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Verified
|
||||||
*/
|
*/
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
if (!$event->user->email_verified_reward) {
|
if (! $event->user->email_verified_reward) {
|
||||||
$event->user->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
|
$event->user->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
|
||||||
$event->user->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
|
$event->user->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,15 @@ class ApplicationApi extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = ['token', 'memo' , 'last_used'];
|
protected $fillable = ['token', 'memo', 'last_used'];
|
||||||
|
|
||||||
protected $primaryKey = 'token';
|
protected $primaryKey = 'token';
|
||||||
|
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $dates = ['last_used'];
|
protected $casts = [
|
||||||
|
'last_used' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
|
@ -29,7 +31,8 @@ class ApplicationApi extends Model
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateLastUsed(){
|
public function updateLastUsed()
|
||||||
|
{
|
||||||
$this->update(['last_used' => now()]);
|
$this->update(['last_used' => now()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,18 @@ class DiscordUser extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"id",
|
'id',
|
||||||
"user_id",
|
'user_id',
|
||||||
"username",
|
'username',
|
||||||
"avatar",
|
'avatar',
|
||||||
"discriminator",
|
'discriminator',
|
||||||
"public_flags",
|
'public_flags',
|
||||||
"flags",
|
'flags',
|
||||||
"locale",
|
'locale',
|
||||||
"mfa_enabled",
|
'mfa_enabled',
|
||||||
"premium_type",
|
'premium_type',
|
||||||
"email",
|
'email',
|
||||||
"verified",
|
'verified',
|
||||||
];
|
];
|
||||||
|
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
@ -30,14 +30,16 @@ class DiscordUser extends Model
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo
|
* @return BelongsTo
|
||||||
*/
|
*/
|
||||||
public function user(){
|
public function user()
|
||||||
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAvatar(){
|
public function getAvatar()
|
||||||
return "https://cdn.discordapp.com/avatars/" . $this->id . "/" . $this->avatar . ".png";
|
{
|
||||||
|
return 'https://cdn.discordapp.com/avatars/'.$this->id.'/'.$this->avatar.'.png';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ class Egg extends Model
|
||||||
$array['environment'] = json_encode([$environment]);
|
$array['environment'] = json_encode([$environment]);
|
||||||
|
|
||||||
self::query()->updateOrCreate([
|
self::query()->updateOrCreate([
|
||||||
'id' => $array['id']
|
'id' => $array['id'],
|
||||||
], array_diff_key($array, array_flip(["id"]))
|
], array_diff_key($array, array_flip(['id']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ class Egg extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description remove eggs that have been deleted on pterodactyl
|
* @description remove eggs that have been deleted on pterodactyl
|
||||||
|
*
|
||||||
* @param Nest $nest
|
* @param Nest $nest
|
||||||
* @param array $eggs
|
* @param array $eggs
|
||||||
*/
|
*/
|
||||||
|
@ -82,7 +83,9 @@ class Egg extends Model
|
||||||
}, $eggs);
|
}, $eggs);
|
||||||
|
|
||||||
$nest->eggs()->each(function (Egg $egg) use ($ids) {
|
$nest->eggs()->each(function (Egg $egg) use ($ids) {
|
||||||
if (!in_array($egg->id, $ids)) $egg->delete();
|
if (! in_array($egg->id, $ids)) {
|
||||||
|
$egg->delete();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Invoice extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'invoice_name',
|
'invoice_name',
|
||||||
'invoice_user',
|
'invoice_user',
|
||||||
'payment_id'
|
'payment_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ class Location extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync locations with pterodactyl panel
|
* Sync locations with pterodactyl panel
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function syncLocations()
|
public static function syncLocations()
|
||||||
|
@ -36,18 +37,18 @@ class Location extends Model
|
||||||
|
|
||||||
//map response
|
//map response
|
||||||
$locations = array_map(function ($val) {
|
$locations = array_map(function ($val) {
|
||||||
return array(
|
return [
|
||||||
'id' => $val['attributes']['id'],
|
'id' => $val['attributes']['id'],
|
||||||
'name' => $val['attributes']['short'],
|
'name' => $val['attributes']['short'],
|
||||||
'description' => $val['attributes']['long']
|
'description' => $val['attributes']['long'],
|
||||||
);
|
];
|
||||||
}, $locations);
|
}, $locations);
|
||||||
|
|
||||||
//update or create
|
//update or create
|
||||||
foreach ($locations as $location) {
|
foreach ($locations as $location) {
|
||||||
self::query()->updateOrCreate(
|
self::query()->updateOrCreate(
|
||||||
[
|
[
|
||||||
'id' => $location['id']
|
'id' => $location['id'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => $location['name'],
|
'name' => $location['name'],
|
||||||
|
@ -61,6 +62,7 @@ class Location extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description remove locations that have been deleted on pterodactyl
|
* @description remove locations that have been deleted on pterodactyl
|
||||||
|
*
|
||||||
* @param array $locations
|
* @param array $locations
|
||||||
*/
|
*/
|
||||||
private static function removeDeletedLocation(array $locations): void
|
private static function removeDeletedLocation(array $locations): void
|
||||||
|
@ -70,7 +72,9 @@ class Location extends Model
|
||||||
}, $locations);
|
}, $locations);
|
||||||
|
|
||||||
self::all()->each(function (Location $location) use ($ids) {
|
self::all()->each(function (Location $location) use ($ids) {
|
||||||
if (!in_array($location->id, $ids)) $location->delete();
|
if (! in_array($location->id, $ids)) {
|
||||||
|
$location->delete();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +82,4 @@ class Location extends Model
|
||||||
{
|
{
|
||||||
return $this->hasMany(Node::class, 'location_id', 'id');
|
return $this->hasMany(Node::class, 'location_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,20 +36,20 @@ class Nest extends Model
|
||||||
|
|
||||||
//map response
|
//map response
|
||||||
$nests = array_map(function ($nest) {
|
$nests = array_map(function ($nest) {
|
||||||
return array(
|
return [
|
||||||
'id' => $nest['attributes']['id'],
|
'id' => $nest['attributes']['id'],
|
||||||
'name' => $nest['attributes']['name'],
|
'name' => $nest['attributes']['name'],
|
||||||
'description' => $nest['attributes']['description'],
|
'description' => $nest['attributes']['description'],
|
||||||
);
|
];
|
||||||
}, $nests);
|
}, $nests);
|
||||||
|
|
||||||
foreach ($nests as $nest) {
|
foreach ($nests as $nest) {
|
||||||
self::query()->updateOrCreate([
|
self::query()->updateOrCreate([
|
||||||
'id' => $nest['id']
|
'id' => $nest['id'],
|
||||||
], [
|
], [
|
||||||
'name' => $nest['name'],
|
'name' => $nest['name'],
|
||||||
'description' => $nest['description'],
|
'description' => $nest['description'],
|
||||||
'disabled' => false
|
'disabled' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ class Nest extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description remove nests that have been deleted on pterodactyl
|
* @description remove nests that have been deleted on pterodactyl
|
||||||
|
*
|
||||||
* @param array $nests
|
* @param array $nests
|
||||||
*/
|
*/
|
||||||
private static function removeDeletedNests(array $nests): void
|
private static function removeDeletedNests(array $nests): void
|
||||||
|
@ -67,7 +68,9 @@ class Nest extends Model
|
||||||
}, $nests);
|
}, $nests);
|
||||||
|
|
||||||
self::all()->each(function (Nest $nest) use ($ids) {
|
self::all()->each(function (Nest $nest) use ($ids) {
|
||||||
if (!in_array($nest->id, $ids)) $nest->delete();
|
if (! in_array($nest->id, $ids)) {
|
||||||
|
$nest->delete();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ class Node extends Model
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@ -37,25 +36,25 @@ class Node extends Model
|
||||||
|
|
||||||
//map response
|
//map response
|
||||||
$nodes = array_map(function ($node) {
|
$nodes = array_map(function ($node) {
|
||||||
return array(
|
return [
|
||||||
'id' => $node['attributes']['id'],
|
'id' => $node['attributes']['id'],
|
||||||
'location_id' => $node['attributes']['location_id'],
|
'location_id' => $node['attributes']['location_id'],
|
||||||
'name' => $node['attributes']['name'],
|
'name' => $node['attributes']['name'],
|
||||||
'description' => $node['attributes']['description'],
|
'description' => $node['attributes']['description'],
|
||||||
);
|
];
|
||||||
}, $nodes);
|
}, $nodes);
|
||||||
|
|
||||||
//update or create
|
//update or create
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
self::query()->updateOrCreate(
|
self::query()->updateOrCreate(
|
||||||
[
|
[
|
||||||
'id' => $node['id']
|
'id' => $node['id'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => $node['name'],
|
'name' => $node['name'],
|
||||||
'description' => $node['description'],
|
'description' => $node['description'],
|
||||||
'location_id' => $node['location_id'],
|
'location_id' => $node['location_id'],
|
||||||
'disabled' => false
|
'disabled' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +63,7 @@ class Node extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description remove nodes that have been deleted on pterodactyl
|
* @description remove nodes that have been deleted on pterodactyl
|
||||||
|
*
|
||||||
* @param array $nodes
|
* @param array $nodes
|
||||||
*/
|
*/
|
||||||
private static function removeDeletedNodes(array $nodes): void
|
private static function removeDeletedNodes(array $nodes): void
|
||||||
|
@ -73,7 +73,9 @@ class Node extends Model
|
||||||
}, $nodes);
|
}, $nodes);
|
||||||
|
|
||||||
self::all()->each(function (Node $node) use ($ids) {
|
self::all()->each(function (Node $node) use ($ids) {
|
||||||
if (!in_array($node->id, $ids)) $node->delete();
|
if (! in_array($node->id, $ids)) {
|
||||||
|
$node->delete();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,27 +15,32 @@ class PartnerDiscount extends Model
|
||||||
'user_id',
|
'user_id',
|
||||||
'partner_discount',
|
'partner_discount',
|
||||||
'registered_user_discount',
|
'registered_user_discount',
|
||||||
'referral_system_commission'
|
'referral_system_commission',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getDiscount()
|
public static function getDiscount()
|
||||||
{
|
{
|
||||||
if($partnerDiscount = PartnerDiscount::where('user_id', Auth::user()->id)->first()){
|
if ($partnerDiscount = PartnerDiscount::where('user_id', Auth::user()->id)->first()) {
|
||||||
return $partnerDiscount->partner_discount;
|
return $partnerDiscount->partner_discount;
|
||||||
}
|
} elseif ($ref_user = DB::table('user_referrals')->where('registered_user_id', '=', Auth::user()->id)->first()) {
|
||||||
else if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', Auth::user()->id)->first()){
|
if ($partnerDiscount = PartnerDiscount::where('user_id', $ref_user->referral_id)->first()) {
|
||||||
if($partnerDiscount = PartnerDiscount::where('user_id', $ref_user->referral_id)->first()){
|
|
||||||
return $partnerDiscount->registered_user_discount;
|
return $partnerDiscount->registered_user_discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCommission($user_id)
|
public static function getCommission($user_id)
|
||||||
{
|
{
|
||||||
if($partnerDiscount = PartnerDiscount::where('user_id', $user_id)->first()){
|
if ($partnerDiscount = PartnerDiscount::where('user_id', $user_id)->first()) {
|
||||||
if($partnerDiscount->referral_system_commission>=0) return $partnerDiscount->referral_system_commission>=0;
|
if ($partnerDiscount->referral_system_commission >= 0) {
|
||||||
|
return $partnerDiscount->referral_system_commission >= 0;
|
||||||
}
|
}
|
||||||
return config("SETTINGS::REFERRAL:PERCENTAGE");
|
}
|
||||||
|
|
||||||
|
return config('SETTINGS::REFERRAL:PERCENTAGE');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,13 +7,20 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
class Payment extends Model
|
class Payment extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use LogsActivity;
|
use LogsActivity;
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,12 +64,12 @@ class Payment extends Model
|
||||||
/**
|
/**
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
*
|
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function formatToCurrency($value, $locale = 'en_US')
|
public function formatToCurrency($value, $locale = 'en_US')
|
||||||
{
|
{
|
||||||
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
return $formatter->formatCurrency($value, $this->currency_code);
|
return $formatter->formatCurrency($value, $this->currency_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,20 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
class Product extends Model
|
class Product extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use LogsActivity;
|
use LogsActivity;
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
@ -29,7 +35,7 @@ class Product extends Model
|
||||||
$product->{$product->getKeyName()} = $client->generateId($size = 21);
|
$product->{$product->getKeyName()} = $client->generateId($size = 21);
|
||||||
});
|
});
|
||||||
|
|
||||||
static::deleting(function(Product $product) {
|
static::deleting(function (Product $product) {
|
||||||
$product->nodes()->detach();
|
$product->nodes()->detach();
|
||||||
$product->eggs()->detach();
|
$product->eggs()->detach();
|
||||||
});
|
});
|
||||||
|
@ -42,12 +48,12 @@ class Product extends Model
|
||||||
|
|
||||||
public function getDailyPrice()
|
public function getDailyPrice()
|
||||||
{
|
{
|
||||||
return ($this->price / 30);
|
return $this->price / 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWeeklyPrice()
|
public function getWeeklyPrice()
|
||||||
{
|
{
|
||||||
return ($this->price / 4);
|
return $this->price / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,14 +67,16 @@ class Product extends Model
|
||||||
/**
|
/**
|
||||||
* @return BelongsToMany
|
* @return BelongsToMany
|
||||||
*/
|
*/
|
||||||
public function eggs() {
|
public function eggs()
|
||||||
|
{
|
||||||
return $this->belongsToMany(Egg::class);
|
return $this->belongsToMany(Egg::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsToMany
|
* @return BelongsToMany
|
||||||
*/
|
*/
|
||||||
public function nodes() {
|
public function nodes()
|
||||||
|
{
|
||||||
return $this->belongsToMany(Node::class);
|
return $this->belongsToMany(Node::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,23 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Http\Client\Response;
|
use Illuminate\Http\Client\Response;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Server
|
* Class Server
|
||||||
* @package App\Models
|
|
||||||
*/
|
*/
|
||||||
class Server extends Model
|
class Server extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use LogsActivity;
|
use LogsActivity;
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -41,24 +47,21 @@ class Server extends Model
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"name",
|
'name',
|
||||||
"description",
|
'description',
|
||||||
"suspended",
|
'suspended',
|
||||||
"identifier",
|
'identifier',
|
||||||
"product_id",
|
'product_id',
|
||||||
"pterodactyl_id",
|
'pterodactyl_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $dates = [
|
protected $casts = [
|
||||||
'suspended'
|
'suspended' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
@ -71,7 +74,7 @@ class Server extends Model
|
||||||
|
|
||||||
static::deleting(function (Server $server) {
|
static::deleting(function (Server $server) {
|
||||||
$response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
$response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
||||||
if ($response->failed() && !is_null($server->pterodactyl_id)) {
|
if ($response->failed() && ! is_null($server->pterodactyl_id)) {
|
||||||
//only return error when it's not a 404 error
|
//only return error when it's not a 404 error
|
||||||
if ($response['errors'][0]['status'] != '404') {
|
if ($response['errors'][0]['status'] != '404') {
|
||||||
throw new Exception($response['errors'][0]['code']);
|
throw new Exception($response['errors'][0]['code']);
|
||||||
|
@ -85,10 +88,9 @@ class Server extends Model
|
||||||
*/
|
*/
|
||||||
public function isSuspended()
|
public function isSuspended()
|
||||||
{
|
{
|
||||||
return !is_null($this->suspended);
|
return ! is_null($this->suspended);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PromiseInterface|Response
|
* @return PromiseInterface|Response
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +100,6 @@ class Server extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function suspend()
|
public function suspend()
|
||||||
|
@ -107,7 +108,7 @@ class Server extends Model
|
||||||
|
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
$this->update([
|
$this->update([
|
||||||
'suspended' => now()
|
'suspended' => now(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,14 +124,13 @@ class Server extends Model
|
||||||
|
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
$this->update([
|
$this->update([
|
||||||
'suspended' => null
|
'suspended' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasOne
|
* @return HasOne
|
||||||
*/
|
*/
|
||||||
|
@ -146,5 +146,4 @@ class Server extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Settings extends Model
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
static::updated(function (Settings $settings) {
|
static::updated(function (Settings $settings) {
|
||||||
Cache::forget(self::CACHE_TAG .':'. $settings->key);
|
Cache::forget(self::CACHE_TAG.':'.$settings->key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,9 @@ class Settings extends Model
|
||||||
*/
|
*/
|
||||||
public static function getValueByKey(string $key, $default = null)
|
public static function getValueByKey(string $key, $default = null)
|
||||||
{
|
{
|
||||||
return Cache::rememberForever(self::CACHE_TAG .':'. $key, function () use ($default, $key) {
|
return Cache::rememberForever(self::CACHE_TAG.':'.$key, function () use ($default, $key) {
|
||||||
$settings = self::find($key);
|
$settings = self::find($key);
|
||||||
|
|
||||||
return $settings ? $settings->value : $default;
|
return $settings ? $settings->value : $default;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,19 @@ namespace App\Models;
|
||||||
use Hidehalo\Nanoid\Client;
|
use Hidehalo\Nanoid\Client;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
use App\Models\Configuration;
|
|
||||||
|
|
||||||
class ShopProduct extends Model
|
class ShopProduct extends Model
|
||||||
{
|
{
|
||||||
use LogsActivity;
|
use LogsActivity;
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -20,13 +27,13 @@ class ShopProduct extends Model
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"type",
|
'type',
|
||||||
"price",
|
'price',
|
||||||
"description",
|
'description',
|
||||||
"display",
|
'display',
|
||||||
"currency_code",
|
'currency_code',
|
||||||
"quantity",
|
'quantity',
|
||||||
"disabled",
|
'disabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
|
@ -43,12 +50,12 @@ class ShopProduct extends Model
|
||||||
/**
|
/**
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
*
|
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function formatToCurrency($value, $locale = 'en_US')
|
public function formatToCurrency($value, $locale = 'en_US')
|
||||||
{
|
{
|
||||||
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
return $formatter->formatCurrency($value, $this->currency_code);
|
return $formatter->formatCurrency($value, $this->currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +66,8 @@ class ShopProduct extends Model
|
||||||
*/
|
*/
|
||||||
public function getTaxPercent()
|
public function getTaxPercent()
|
||||||
{
|
{
|
||||||
$tax = config("SETTINGS::PAYMENTS:SALES_TAX");
|
$tax = config('SETTINGS::PAYMENTS:SALES_TAX');
|
||||||
|
|
||||||
return $tax < 0 ? 0 : $tax;
|
return $tax < 0 ? 0 : $tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,36 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
|
class Ticket extends Model
|
||||||
|
{
|
||||||
|
use LogsActivity;
|
||||||
|
|
||||||
class Ticket extends Model {
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id', 'ticketcategory_id', 'ticket_id', 'title', 'priority', 'message', 'status', 'server'
|
'user_id', 'ticketcategory_id', 'ticket_id', 'title', 'priority', 'message', 'status', 'server',
|
||||||
];
|
];
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
|
|
||||||
public function ticketcategory(){
|
public function ticketcategory()
|
||||||
return $this->belongsTo(TicketCategory::class);}
|
{
|
||||||
|
return $this->belongsTo(TicketCategory::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function ticketcomments(){
|
public function ticketcomments()
|
||||||
return $this->hasMany(TicketComment::class);}
|
{
|
||||||
|
return $this->hasMany(TicketComment::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function user(){
|
public function user()
|
||||||
return $this->belongsTo(User::class);}
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,10 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class TicketBlacklist extends Model {
|
class TicketBlacklist extends Model
|
||||||
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id', 'status', 'reason'
|
'user_id', 'status', 'reason',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
@ -14,4 +15,3 @@ class TicketBlacklist extends Model {
|
||||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class TicketCategory extends Model {
|
class TicketCategory extends Model
|
||||||
|
{
|
||||||
protected $fillable = ['name'];
|
protected $fillable = ['name'];
|
||||||
|
|
||||||
public function tickets(){
|
public function tickets()
|
||||||
return $this->hasMany(Ticket::class);}
|
{
|
||||||
|
return $this->hasMany(Ticket::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,24 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class TicketComment extends Model {
|
class TicketComment extends Model
|
||||||
protected $fillable = [
|
{
|
||||||
'ticket_id', 'user_id', 'ticketcomment'
|
protected $fillable = [
|
||||||
];
|
'ticket_id', 'user_id', 'ticketcomment',
|
||||||
|
];
|
||||||
|
|
||||||
public function ticketcategory(){
|
public function ticketcategory()
|
||||||
return $this->belongsTo(TicketCategory::class);}
|
{
|
||||||
|
return $this->belongsTo(TicketCategory::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function ticket(){
|
public function ticket()
|
||||||
return $this->belongsTo(Ticket::class);}
|
{
|
||||||
|
return $this->belongsTo(Ticket::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function user(){
|
public function user()
|
||||||
return $this->belongsTo(User::class);}
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,6 @@ class UsefulLink extends Model
|
||||||
'icon',
|
'icon',
|
||||||
'title',
|
'title',
|
||||||
'link',
|
'link',
|
||||||
'description'
|
'description',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\CausesActivity;
|
use Spatie\Activitylog\Traits\CausesActivity;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class User
|
* Class User
|
||||||
* @package App\Models
|
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable implements MustVerifyEmail
|
class User extends Authenticatable implements MustVerifyEmail
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
'server_limit',
|
'server_limit',
|
||||||
'last_seen',
|
'last_seen',
|
||||||
'ip',
|
'ip',
|
||||||
'pterodactyl_id'
|
'pterodactyl_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
'discord_verified_at',
|
'discord_verified_at',
|
||||||
'avatar',
|
'avatar',
|
||||||
'suspended',
|
'suspended',
|
||||||
'referral_code'
|
'referral_code',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,9 +85,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
'server_limit' => 'float',
|
'server_limit' => 'float',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
@ -119,7 +116,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
|
|
||||||
$user->vouchers()->detach();
|
$user->vouchers()->detach();
|
||||||
|
|
||||||
|
|
||||||
$user->discordUser()->delete();
|
$user->discordUser()->delete();
|
||||||
|
|
||||||
Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}");
|
Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}");
|
||||||
|
@ -174,9 +170,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
return $this->hasOne(DiscordUser::class);
|
return $this->hasOne(DiscordUser::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function sendEmailVerificationNotification()
|
public function sendEmailVerificationNotification()
|
||||||
{
|
{
|
||||||
$this->notify(new QueuedVerifyEmail);
|
$this->notify(new QueuedVerifyEmail);
|
||||||
|
@ -199,7 +192,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function suspend()
|
public function suspend()
|
||||||
|
@ -209,7 +201,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->update([
|
$this->update([
|
||||||
'suspended' => true
|
'suspended' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -227,7 +219,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->update([
|
$this->update([
|
||||||
'suspended' => false
|
'suspended' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -256,8 +248,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
|
// $avatar = "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
|
return 'https://www.gravatar.com/avatar/'.md5(strtolower(trim($this->email)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,9 +270,14 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
public function getVerifiedStatus()
|
public function getVerifiedStatus()
|
||||||
{
|
{
|
||||||
$status = '';
|
$status = '';
|
||||||
if ($this->hasVerifiedEmail()) $status .= 'email ';
|
if ($this->hasVerifiedEmail()) {
|
||||||
if ($this->discordUser()->exists()) $status .= 'discord';
|
$status .= 'email ';
|
||||||
|
}
|
||||||
|
if ($this->discordUser()->exists()) {
|
||||||
|
$status .= 'discord';
|
||||||
|
}
|
||||||
$status = str_replace(' ', '/', $status);
|
$status = str_replace(' ', '/', $status);
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,4 +294,12 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
'email_verified_at' => null,
|
'email_verified_at' => null,
|
||||||
])->save();
|
])->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,22 @@ use Exception;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Voucher
|
* Class Voucher
|
||||||
* @package App\Models
|
|
||||||
*/
|
*/
|
||||||
class Voucher extends Model
|
class Voucher extends Model
|
||||||
{
|
{
|
||||||
use HasFactory, LogsActivity;
|
use HasFactory, LogsActivity;
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
-> logOnlyDirty()
|
||||||
|
-> logOnly(['*'])
|
||||||
|
-> dontSubmitEmptyLogs();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
@ -27,19 +33,15 @@ class Voucher extends Model
|
||||||
'expires_at',
|
'expires_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
|
||||||
'expires_at'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be cast to native types.
|
* The attributes that should be cast to native types.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
'expires_at' => 'datetime',
|
||||||
'credits' => 'float',
|
'credits' => 'float',
|
||||||
'uses' => 'integer'
|
'uses' => 'integer', ];
|
||||||
];
|
|
||||||
|
|
||||||
protected $appends = ['used', 'status'];
|
protected $appends = ['used', 'status'];
|
||||||
|
|
||||||
|
@ -59,9 +61,6 @@ class Voucher extends Model
|
||||||
return $this->getStatus();
|
return $this->getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
@ -84,9 +83,13 @@ class Voucher extends Model
|
||||||
*/
|
*/
|
||||||
public function getStatus()
|
public function getStatus()
|
||||||
{
|
{
|
||||||
if ($this->users()->count() >= $this->uses) return 'USES_LIMIT_REACHED';
|
if ($this->users()->count() >= $this->uses) {
|
||||||
if (!is_null($this->expires_at)) {
|
return 'USES_LIMIT_REACHED';
|
||||||
if ($this->expires_at->isPast()) return __('EXPIRED');
|
}
|
||||||
|
if (! is_null($this->expires_at)) {
|
||||||
|
if ($this->expires_at->isPast()) {
|
||||||
|
return __('EXPIRED');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return __('VALID');
|
return __('VALID');
|
||||||
|
@ -95,6 +98,7 @@ class Voucher extends Model
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return float
|
* @return float
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function redeem(User $user)
|
public function redeem(User $user)
|
||||||
|
|
|
@ -10,7 +10,6 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
@ -48,7 +47,7 @@ class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject(__('Payment Confirmation'))
|
->subject(__('Payment Confirmation'))
|
||||||
->markdown('mail.payment.confirmed' , ['payment' => $this->payment]);
|
->markdown('mail.payment.confirmed', ['payment' => $this->payment]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,8 +59,8 @@ class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => __("Payment Confirmed!"),
|
'title' => __('Payment Confirmed!'),
|
||||||
'content' => __("Payment Confirmed!"),
|
'content' => __('Payment Confirmed!'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,24 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class DynamicNotification extends Notification
|
class DynamicNotification extends Notification
|
||||||
|
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $via;
|
private $via;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $database;
|
private $database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var MailMessage
|
* @var MailMessage
|
||||||
*/
|
*/
|
||||||
private $mail;
|
private $mail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new notification instance.
|
* Create a new notification instance.
|
||||||
*
|
*
|
||||||
|
@ -50,6 +53,7 @@ class DynamicNotification extends Notification
|
||||||
{
|
{
|
||||||
return $this->mail;
|
return $this->mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
* Get the array representation of the notification.
|
||||||
*
|
*
|
||||||
|
|
|
@ -10,7 +10,6 @@ use Illuminate\Notifications\Notification;
|
||||||
use LaravelDaily\Invoices\Invoice;
|
use LaravelDaily\Invoices\Invoice;
|
||||||
|
|
||||||
class InvoiceNotification extends Notification
|
class InvoiceNotification extends Notification
|
||||||
|
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
|
@ -20,7 +19,9 @@ class InvoiceNotification extends Notification
|
||||||
* * @var invoice
|
* * @var invoice
|
||||||
*/
|
*/
|
||||||
private $invoice;
|
private $invoice;
|
||||||
|
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
private $payment;
|
private $payment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +58,13 @@ class InvoiceNotification extends Notification
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject(__('Your Payment was successful!'))
|
->subject(__('Your Payment was successful!'))
|
||||||
->greeting(__('Hello').',')
|
->greeting(__('Hello').',')
|
||||||
->line(__("Your payment was processed successfully!"))
|
->line(__('Your payment was processed successfully!'))
|
||||||
->line(__('Status').': ' . $this->payment->status)
|
->line(__('Status').': '.$this->payment->status)
|
||||||
->line(__('Price').': ' . $this->payment->formatToCurrency($this->payment->total_price))
|
->line(__('Price').': '.$this->payment->formatToCurrency($this->payment->total_price))
|
||||||
->line(__('Type').': ' . $this->payment->type)
|
->line(__('Type').': '.$this->payment->type)
|
||||||
->line(__('Amount').': ' . $this->payment->amount)
|
->line(__('Amount').': '.$this->payment->amount)
|
||||||
->line(__('Balance').': ' . number_format($this->user->credits,2))
|
->line(__('Balance').': '.number_format($this->user->credits, 2))
|
||||||
->line(__('User ID').': ' . $this->payment->user_id)
|
->line(__('User ID').': '.$this->payment->user_id)
|
||||||
->attach(storage_path('app/invoice/' . $this->user->id . '/' . now()->format('Y') . '/' . $this->invoice->filename));
|
->attach(storage_path('app/invoice/'.$this->user->id.'/'.now()->format('Y').'/'.$this->invoice->filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@ namespace App\Notifications;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ReferralNotification extends Notification
|
class ReferralNotification extends Notification
|
||||||
|
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var User
|
* @var User
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +46,13 @@ class ReferralNotification extends Notification
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => __("Someone registered using your Code!"),
|
'title' => __('Someone registered using your Code!'),
|
||||||
'content' => "
|
'content' => '
|
||||||
<p>You received ".config('SETTINGS::REFERRAL::REWARD')." ".config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME')."</p>
|
<p>You received '.config('SETTINGS::REFERRAL::REWARD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'</p>
|
||||||
<p>because ".$this->ref_user->name." registered with your Referral-Code!</p>
|
<p>because '.$this->ref_user->name.' registered with your Referral-Code!</p>
|
||||||
<p>Thank you very much for supporting us!.</p>
|
<p>Thank you very much for supporting us!.</p>
|
||||||
<p>".config('app.name', 'Laravel')."</p>
|
<p>'.config('app.name', 'Laravel').'</p>
|
||||||
",
|
',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class ServerCreationError extends Notification
|
class ServerCreationError extends Notification
|
||||||
|
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Server
|
* @var Server
|
||||||
*/
|
*/
|
||||||
|
@ -46,13 +45,13 @@ class ServerCreationError extends Notification
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => __("Server Creation Error"),
|
'title' => __('Server Creation Error'),
|
||||||
'content' => "
|
'content' => "
|
||||||
<p>Hello <strong>{$this->server->User->name}</strong>, An unexpected error has occurred...</p>
|
<p>Hello <strong>{$this->server->User->name}</strong>, An unexpected error has occurred...</p>
|
||||||
<p>There was a problem creating your server on our pterodactyl panel. There are likely no allocations or rooms left on the selected node. Please contact one of our support members through our discord server to get this resolved asap!</p>
|
<p>There was a problem creating your server on our pterodactyl panel. There are likely no allocations or rooms left on the selected node. Please contact one of our support members through our discord server to get this resolved asap!</p>
|
||||||
<p>We thank you for your patience and our deepest apologies for this inconvenience.</p>
|
<p>We thank you for your patience and our deepest apologies for this inconvenience.</p>
|
||||||
<p>".config('app.name', 'Laravel')."</p>
|
<p>".config('app.name', 'Laravel').'</p>
|
||||||
",
|
',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ServersSuspendedNotification extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
return ['mail' , 'database'];
|
return ['mail', 'database'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +43,7 @@ class ServersSuspendedNotification extends Notification implements ShouldQueue
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject(__('Your servers have been suspended!'))
|
->subject(__('Your servers have been suspended!'))
|
||||||
->greeting(__('Your servers have been suspended!'))
|
->greeting(__('Your servers have been suspended!'))
|
||||||
->line(__("To automatically re-enable your server/s, you need to purchase more credits."))
|
->line(__('To automatically re-enable your server/s, you need to purchase more credits.'))
|
||||||
->action(__('Purchase credits'), route('store.index'))
|
->action(__('Purchase credits'), route('store.index'))
|
||||||
->line(__('If you have any questions please let us know.'));
|
->line(__('If you have any questions please let us know.'));
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,12 @@ class ServersSuspendedNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => __('Your servers have been suspended!'),
|
'title' => __('Your servers have been suspended!'),
|
||||||
'content' => "
|
'content' => '
|
||||||
<h5>". __('Your servers have been suspended!')."</h5>
|
<h5>'.__('Your servers have been suspended!').'</h5>
|
||||||
<p>". __("To automatically re-enable your server/s, you need to purchase more credits.")."</p>
|
<p>'.__('To automatically re-enable your server/s, you need to purchase more credits.').'</p>
|
||||||
<p>". __('If you have any questions please let us know.')."</p>
|
<p>'.__('If you have any questions please let us know.').'</p>
|
||||||
<p>". __('Regards').",<br />" . config('app.name', 'Laravel') . "</p>
|
<p>'.__('Regards').',<br />'.config('app.name', 'Laravel').'</p>
|
||||||
",
|
',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class AdminCreateNotification extends Notification implements ShouldQueue
|
class AdminCreateNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private Ticket $ticket;
|
private Ticket $ticket;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,8 @@ class AdminCreateNotification extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
$via = ['mail','database'];
|
$via = ['mail', 'database'];
|
||||||
|
|
||||||
return $via;
|
return $via;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +52,8 @@ class AdminCreateNotification extends Notification implements ShouldQueue
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title)
|
->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
|
||||||
->markdown('mail.ticket.admin.create' , ['ticket' => $this->ticket, 'user' => $this->user]);
|
->markdown('mail.ticket.admin.create', ['ticket' => $this->ticket, 'user' => $this->user]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +65,7 @@ class AdminCreateNotification extends Notification implements ShouldQueue
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => '[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title,
|
'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
|
||||||
'content' => "Ticket With ID : {$this->ticket->ticket_id} has been opened by <strong>{$this->user->name}</strong>",
|
'content' => "Ticket With ID : {$this->ticket->ticket_id} has been opened by <strong>{$this->user->name}</strong>",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,14 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class AdminReplyNotification extends Notification implements ShouldQueue
|
class AdminReplyNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private Ticket $ticket;
|
private Ticket $ticket;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
private $newmessage;
|
private $newmessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,8 @@ class AdminReplyNotification extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
$via = ['mail','database'];
|
$via = ['mail', 'database'];
|
||||||
|
|
||||||
return $via;
|
return $via;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +55,8 @@ class AdminReplyNotification extends Notification implements ShouldQueue
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title)
|
->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
|
||||||
->markdown('mail.ticket.admin.reply' , ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
|
->markdown('mail.ticket.admin.reply', ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +68,7 @@ class AdminReplyNotification extends Notification implements ShouldQueue
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => '[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title,
|
'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
|
||||||
'content' => "
|
'content' => "
|
||||||
<p>Ticket With ID : {$this->ticket->ticket_id} has had a new reply posted by <strong>{$this->user->name}</strong></p>
|
<p>Ticket With ID : {$this->ticket->ticket_id} has had a new reply posted by <strong>{$this->user->name}</strong></p>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -10,7 +10,6 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class CreateNotification extends Notification implements ShouldQueue
|
class CreateNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
@ -35,7 +34,8 @@ class CreateNotification extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
$via = ['mail','database'];
|
$via = ['mail', 'database'];
|
||||||
|
|
||||||
return $via;
|
return $via;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ class CreateNotification extends Notification implements ShouldQueue
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title)
|
->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
|
||||||
->markdown('mail.ticket.user.create' , ['ticket' => $this->ticket]);
|
->markdown('mail.ticket.user.create', ['ticket' => $this->ticket]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ class CreateNotification extends Notification implements ShouldQueue
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => '[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title,
|
'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
|
||||||
'content' => "Your Ticket has been Created With ID : {$this->ticket->ticket_id}",
|
'content' => "Your Ticket has been Created With ID : {$this->ticket->ticket_id}",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Notifications\Ticket\User;
|
namespace App\Notifications\Ticket\User;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
@ -11,13 +11,14 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class ReplyNotification extends Notification implements ShouldQueue
|
class ReplyNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private Ticket $ticket;
|
private Ticket $ticket;
|
||||||
|
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
private $newmessage;
|
private $newmessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,8 @@ class ReplyNotification extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
$via = ['mail','database'];
|
$via = ['mail', 'database'];
|
||||||
|
|
||||||
return $via;
|
return $via;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +55,8 @@ class ReplyNotification extends Notification implements ShouldQueue
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title)
|
->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
|
||||||
->markdown('mail.ticket.user.reply' , ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
|
->markdown('mail.ticket.user.reply', ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +68,7 @@ class ReplyNotification extends Notification implements ShouldQueue
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => '[Ticket ID: ' . $this->ticket->ticket_id . '] ' . $this->ticket->title,
|
'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
|
||||||
'content' => "
|
'content' => "
|
||||||
<p>Ticket With ID : {$this->ticket->ticket_id} A response has been added to your ticket. Please see below for our response!</p>
|
<p>Ticket With ID : {$this->ticket->ticket_id} A response has been added to your ticket. Please see below for our response!</p>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Settings;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
@ -37,26 +36,27 @@ class WelcomeMessage extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
return ['database'];
|
return ['database'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AdditionalLines()
|
public function AdditionalLines()
|
||||||
{
|
{
|
||||||
|
$AdditionalLine = '';
|
||||||
$AdditionalLine = "";
|
|
||||||
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
||||||
$AdditionalLine .= __("Verifying your e-mail address will grant you ") . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'). " " . __("additional") . " " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
$AdditionalLine .= __('Verifying your e-mail address will grant you ').config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL').' '.__('additional').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'. <br />';
|
||||||
}
|
}
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
||||||
$AdditionalLine .= __("Verifying your e-mail will also increase your Server Limit by ") . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . ". <br />";
|
$AdditionalLine .= __('Verifying your e-mail will also increase your Server Limit by ').config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL').'. <br />';
|
||||||
}
|
}
|
||||||
$AdditionalLine .= "<br />";
|
$AdditionalLine .= '<br />';
|
||||||
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
||||||
$AdditionalLine .= __("You can also verify your discord account to get another ") . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
$AdditionalLine .= __('You can also verify your discord account to get another ').config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'. <br />';
|
||||||
}
|
}
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
||||||
$AdditionalLine .= __("Verifying your Discord account will also increase your Server Limit by ") . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . ". <br />";
|
$AdditionalLine .= __('Verifying your Discord account will also increase your Server Limit by ').config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD').'. <br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $AdditionalLine;
|
return $AdditionalLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array representation of the notification.
|
* Get the array representation of the notification.
|
||||||
*
|
*
|
||||||
|
@ -65,21 +65,20 @@ class WelcomeMessage extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => __("Getting started!"),
|
'title' => __('Getting started!'),
|
||||||
'content' => "
|
'content' => '
|
||||||
<p> ".__("Hello")." <strong>{$this->user->name}</strong>, ".__("Welcome to our dashboard")."!</p>
|
<p> '.__('Hello')." <strong>{$this->user->name}</strong>, ".__('Welcome to our dashboard').'!</p>
|
||||||
<h5>".__("Verification")."</h5>
|
<h5>'.__('Verification').'</h5>
|
||||||
<p>".__("You can verify your e-mail address and link/verify your Discord account.")."</p>
|
<p>'.__('You can verify your e-mail address and link/verify your Discord account.').'</p>
|
||||||
<p>
|
<p>
|
||||||
" . $this->AdditionalLines() . "
|
'.$this->AdditionalLines().'
|
||||||
</p>
|
</p>
|
||||||
<h5>".__("Information")."</h5>
|
<h5>'.__('Information').'</h5>
|
||||||
<p>".__("This dashboard can be used to create and delete servers").".<br /> ".__("These servers can be used and managed on our pterodactyl panel").".<br /> ".__("If you have any questions, please join our Discord server and #create-a-ticket").".</p>
|
<p>'.__('This dashboard can be used to create and delete servers').'.<br /> '.__('These servers can be used and managed on our pterodactyl panel').'.<br /> '.__('If you have any questions, please join our Discord server and #create-a-ticket').'.</p>
|
||||||
<p>".__("We hope you can enjoy this hosting experience and if you have any suggestions please let us know")."!</p>
|
<p>'.__('We hope you can enjoy this hosting experience and if you have any suggestions please let us know').'!</p>
|
||||||
<p>".__("Regards").",<br />" . config('app.name', 'Laravel') . "</p>
|
<p>'.__('Regards').',<br />'.config('app.name', 'Laravel').'</p>
|
||||||
",
|
',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Models\Settings;
|
use App\Models\Settings;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Pagination\Paginator;
|
use Illuminate\Pagination\Paginator;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,9 @@ class AppServiceProvider extends ServiceProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
//if none of result array is true. it sets ok to false
|
//if none of result array is true. it sets ok to false
|
||||||
if (!in_array(true, $result)) {
|
if (! in_array(true, $result)) {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
$validator->setCustomMessages(['multiple_date_format' => 'The format must be one of ' . join(",", $parameters)]);
|
$validator->setCustomMessages(['multiple_date_format' => 'The format must be one of '.implode(',', $parameters)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ok;
|
return $ok;
|
||||||
|
@ -88,10 +88,9 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Artisan::call('queue:restart');
|
Artisan::call('queue:restart');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set Recaptcha API Config
|
// Set Recaptcha API Config
|
||||||
// Load recaptcha package if recaptcha is enabled
|
// Load recaptcha package if recaptcha is enabled
|
||||||
if(config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
|
if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
|
||||||
$this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class);
|
$this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,29 +106,27 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Artisan::call('cache:clear');
|
Artisan::call('cache:clear');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stringfromfile = file(base_path().'/.git/HEAD');
|
$stringfromfile = file(base_path().'/.git/HEAD');
|
||||||
|
|
||||||
$firstLine = $stringfromfile[0]; //get the string from the array
|
$firstLine = $stringfromfile[0]; //get the string from the array
|
||||||
|
|
||||||
$explodedstring = explode("/", $firstLine, 3); //seperate out by the "/" in the string
|
$explodedstring = explode('/', $firstLine, 3); //seperate out by the "/" in the string
|
||||||
|
|
||||||
$branchname = $explodedstring[2]; //get the one that is always the branch name
|
$branchname = $explodedstring[2]; //get the one that is always the branch name
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$branchname = "unknown";
|
$branchname = 'unknown';
|
||||||
Log::error($e);
|
Log::error($e);
|
||||||
}
|
}
|
||||||
config(['BRANCHNAME' => $branchname]);
|
config(['BRANCHNAME' => $branchname]);
|
||||||
|
|
||||||
|
|
||||||
// Set Discord-API Config
|
// Set Discord-API Config
|
||||||
config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]);
|
config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]);
|
||||||
config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]);
|
config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log("Settings Error: Could not load settings from database. The Installation probably is not done yet.");
|
error_log('Settings Error: Could not load settings from database. The Installation probably is not done yet.');
|
||||||
error_log($e);
|
error_log($e);
|
||||||
Log::error("Settings Error: Could not load settings from database. The Installation probably is not done yet.");
|
Log::error('Settings Error: Could not load settings from database. The Installation probably is not done yet.');
|
||||||
Log::error($e);
|
Log::error($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Gate;
|
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ class EventServiceProvider extends ServiceProvider
|
||||||
SendEmailVerificationNotification::class,
|
SendEmailVerificationNotification::class,
|
||||||
],
|
],
|
||||||
UserUpdateCreditsEvent::class => [
|
UserUpdateCreditsEvent::class => [
|
||||||
UnsuspendServers::class
|
UnsuspendServers::class,
|
||||||
],
|
],
|
||||||
SocialiteWasCalled::class => [
|
SocialiteWasCalled::class => [
|
||||||
// ... other providers
|
// ... other providers
|
||||||
|
@ -43,4 +43,14 @@ class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if events and listeners should be automatically discovered.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function shouldDiscoverEvents()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public const HOME = '/home';
|
public const HOME = '/home';
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller namespace for the application.
|
|
||||||
*
|
|
||||||
* When present, controller route declarations will automatically be prefixed with this namespace.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
// protected $namespace = 'App\\Http\\Controllers';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define your route model bindings, pattern filters, etc.
|
* Define your route model bindings, pattern filters, etc.
|
||||||
*
|
*
|
||||||
|
@ -40,13 +31,10 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
$this->routes(function () {
|
$this->routes(function () {
|
||||||
Route::prefix('api')
|
Route::prefix('api')
|
||||||
->middleware('api')
|
->middleware('api')
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/api.php'));
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
Route::middleware('web')
|
Route::middleware('web')
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/web.php'));
|
->group(base_path('routes/web.php'));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +46,10 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
protected function configureRateLimiting()
|
protected function configureRateLimiting()
|
||||||
{
|
{
|
||||||
RateLimiter::for('api', function (Request $request) {
|
RateLimiter::for('api', function (Request $request) {
|
||||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||||
});
|
});
|
||||||
RateLimiter::for('web', function (Request $request) {
|
RateLimiter::for('web', function (Request $request) {
|
||||||
return Limit::perMinute(40)->by(optional($request->user())->id ?: $request->ip());
|
return Limit::perMinute(40)->by($request->user()?->id ?: $request->ip());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,33 +12,34 @@
|
||||||
"ext-intl": "*",
|
"ext-intl": "*",
|
||||||
"biscolab/laravel-recaptcha": "^5.4",
|
"biscolab/laravel-recaptcha": "^5.4",
|
||||||
"doctrine/dbal": "^3.1",
|
"doctrine/dbal": "^3.1",
|
||||||
"fideloper/proxy": "^4.4",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
|
||||||
"hidehalo/nanoid-php": "^1.1",
|
"hidehalo/nanoid-php": "^1.1",
|
||||||
"kkomelin/laravel-translatable-string-exporter": "^1.14",
|
"kkomelin/laravel-translatable-string-exporter": "^1.15",
|
||||||
"laravel/framework": "^8.12",
|
"laravel/framework": "^9.46",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.7",
|
||||||
"laravel/ui": "^3.2",
|
"laravel/ui": "^3.3",
|
||||||
"laraveldaily/laravel-invoices": "^2.0",
|
"laraveldaily/laravel-invoices": "^3.0",
|
||||||
|
"league/flysystem-aws-s3-v3": "^3.0",
|
||||||
"paypal/paypal-checkout-sdk": "^1.0",
|
"paypal/paypal-checkout-sdk": "^1.0",
|
||||||
"paypal/rest-api-sdk-php": "^1.14",
|
"paypal/rest-api-sdk-php": "^1.14",
|
||||||
"socialiteproviders/discord": "^4.1",
|
"socialiteproviders/discord": "^4.1",
|
||||||
"spatie/laravel-activitylog": "^3.16",
|
"spatie/laravel-activitylog": "^4.4",
|
||||||
"spatie/laravel-query-builder": "^3.6",
|
"spatie/laravel-query-builder": "^5.0",
|
||||||
"spatie/laravel-validation-rules": "^3.0",
|
"spatie/laravel-validation-rules": "^3.2",
|
||||||
"stripe/stripe-php": "^7.107",
|
"stripe/stripe-php": "^7.107",
|
||||||
"symfony/intl": "^5.4",
|
"symfony/http-client": "^6.2",
|
||||||
"yajra/laravel-datatables-oracle": "~9.0"
|
"symfony/intl": "^6.0",
|
||||||
|
"symfony/mailgun-mailer": "^6.2",
|
||||||
|
"yajra/laravel-datatables-oracle": "^9.19"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.6",
|
"barryvdh/laravel-debugbar": "^3.6",
|
||||||
"facade/ignition": "^2.5",
|
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
"laravel/sail": "^1.0.1",
|
"laravel/sail": "^1.15",
|
||||||
"mockery/mockery": "^1.4.2",
|
"mockery/mockery": "^1.4.4",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^6.3",
|
||||||
"phpunit/phpunit": "^9.3.3"
|
"phpunit/phpunit": "^9.5.10",
|
||||||
|
"spatie/laravel-ignition": "^1.4"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
|
@ -76,6 +77,9 @@
|
||||||
],
|
],
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
"@php artisan key:generate --ansi"
|
"@php artisan key:generate --ansi"
|
||||||
|
],
|
||||||
|
"post-update-cmd": [
|
||||||
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3690
composer.lock
generated
3690
composer.lock
generated
File diff suppressed because it is too large
Load diff
52
config/activitylog.php
Normal file
52
config/activitylog.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If set to false, no activities will be saved to the database.
|
||||||
|
*/
|
||||||
|
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When the clean-command is executed, all recording activities older than
|
||||||
|
* the number of days specified here will be deleted.
|
||||||
|
*/
|
||||||
|
'delete_records_older_than_days' => 365,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If no log name is passed to the activity() helper
|
||||||
|
* we use this default log name.
|
||||||
|
*/
|
||||||
|
'default_log_name' => 'default',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You can specify an auth driver here that gets user models.
|
||||||
|
* If this is null we'll use the current Laravel auth driver.
|
||||||
|
*/
|
||||||
|
'default_auth_driver' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If set to true, the subject returns soft deleted models.
|
||||||
|
*/
|
||||||
|
'subject_returns_soft_deleted_models' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This model will be used to log activity.
|
||||||
|
* It should implement the Spatie\Activitylog\Contracts\Activity interface
|
||||||
|
* and extend Illuminate\Database\Eloquent\Model.
|
||||||
|
*/
|
||||||
|
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the name of the table that will be created by the migration and
|
||||||
|
* used by the Activity model shipped with this package.
|
||||||
|
*/
|
||||||
|
'table_name' => 'activity_log',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the database connection that will be used by the migration and
|
||||||
|
* the Activity model shipped with this package. In case it's not set
|
||||||
|
* Laravel's database.default will be used instead.
|
||||||
|
*/
|
||||||
|
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
|
||||||
|
];
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'version' => '0.8.4',
|
'version' => '0.8.4',
|
||||||
|
@ -41,7 +43,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'debug' => (bool)env('APP_DEBUG', false),
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -71,7 +73,6 @@ return [
|
||||||
|
|
||||||
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Locale Configuration
|
| Application Locale Configuration
|
||||||
|
@ -83,7 +84,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'locale' => "en",
|
'locale' => 'en',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -96,8 +97,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'available_locales' => array_map('basename', preg_replace('/\\.[^.\\s]{3,4}$/', '', glob(resource_path() . "/lang/*.json", GLOB_BRACE))),
|
'available_locales' => array_map('basename', preg_replace('/\\.[^.\\s]{3,4}$/', '', glob(resource_path().'/lang/*.json', GLOB_BRACE))),
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -140,6 +140,24 @@ return [
|
||||||
|
|
||||||
'cipher' => 'AES-256-CBC',
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maintenance Mode Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options determine the driver used to determine and
|
||||||
|
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||||
|
| allow maintenance mode to be controlled across multiple machines.
|
||||||
|
|
|
||||||
|
| Supported drivers: "file", "cache"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'maintenance' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
// 'store' => 'redis',
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Autoloaded Service Providers
|
| Autoloaded Service Providers
|
||||||
|
@ -179,7 +197,6 @@ return [
|
||||||
Illuminate\Validation\ValidationServiceProvider::class,
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
Illuminate\View\ViewServiceProvider::class,
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Package Service Providers...
|
* Package Service Providers...
|
||||||
*/
|
*/
|
||||||
|
@ -196,7 +213,6 @@ return [
|
||||||
|
|
||||||
KKomelin\TranslatableStringExporter\Providers\ExporterServiceProvider::class,
|
KKomelin\TranslatableStringExporter\Providers\ExporterServiceProvider::class,
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -210,46 +226,8 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'aliases' => [
|
'aliases' => Facade::defaultAliases()->merge([
|
||||||
|
|
||||||
'App' => Illuminate\Support\Facades\App::class,
|
|
||||||
'Arr' => Illuminate\Support\Arr::class,
|
|
||||||
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
|
||||||
'Auth' => Illuminate\Support\Facades\Auth::class,
|
|
||||||
'Blade' => Illuminate\Support\Facades\Blade::class,
|
|
||||||
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
|
||||||
'Bus' => Illuminate\Support\Facades\Bus::class,
|
|
||||||
'Cache' => Illuminate\Support\Facades\Cache::class,
|
|
||||||
'Config' => Illuminate\Support\Facades\Config::class,
|
|
||||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
|
||||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
|
||||||
'DB' => Illuminate\Support\Facades\DB::class,
|
|
||||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
|
||||||
'Event' => Illuminate\Support\Facades\Event::class,
|
|
||||||
'File' => Illuminate\Support\Facades\File::class,
|
|
||||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
|
||||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
|
||||||
'Http' => Illuminate\Support\Facades\Http::class,
|
|
||||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
|
||||||
'Log' => Illuminate\Support\Facades\Log::class,
|
|
||||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
|
||||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
|
||||||
'Password' => Illuminate\Support\Facades\Password::class,
|
|
||||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
|
||||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
|
||||||
// 'Redis' => Illuminate\Support\Facades\Redis::class,
|
|
||||||
'Request' => Illuminate\Support\Facades\Request::class,
|
|
||||||
'Response' => Illuminate\Support\Facades\Response::class,
|
|
||||||
'Route' => Illuminate\Support\Facades\Route::class,
|
|
||||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
|
||||||
'Session' => Illuminate\Support\Facades\Session::class,
|
|
||||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
|
||||||
'Str' => Illuminate\Support\Str::class,
|
|
||||||
'URL' => Illuminate\Support\Facades\URL::class,
|
|
||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
|
||||||
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
|
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
|
||||||
|
])->toArray(),
|
||||||
],
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -31,7 +31,7 @@ return [
|
||||||
| users are actually retrieved out of your database or other storage
|
| users are actually retrieved out of your database or other storage
|
||||||
| mechanisms used by this application to persist your user's data.
|
| mechanisms used by this application to persist your user's data.
|
||||||
|
|
|
|
||||||
| Supported: "session", "token"
|
| Supported: "session"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ return [
|
||||||
| than one user table or model in the application and you want to have
|
| than one user table or model in the application and you want to have
|
||||||
| separate password reset settings based on the specific user types.
|
| separate password reset settings based on the specific user types.
|
||||||
|
|
|
|
||||||
| The expire time is the number of minutes that the reset token should be
|
| The expire time is the number of minutes that each reset token will be
|
||||||
| considered valid. This security feature keeps tokens short-lived so
|
| considered valid. This security feature keeps tokens short-lived so
|
||||||
| they have less time to be guessed. You may change this as needed.
|
| they have less time to be guessed. You may change this as needed.
|
||||||
|
|
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ return [
|
||||||
| framework when an event needs to be broadcast. You may set this to
|
| framework when an event needs to be broadcast. You may set this to
|
||||||
| any of the connections defined in the "connections" array below.
|
| any of the connections defined in the "connections" array below.
|
||||||
|
|
|
|
||||||
| Supported: "pusher", "redis", "log", "null"
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,8 +36,14 @@ return [
|
||||||
'secret' => env('PUSHER_APP_SECRET'),
|
'secret' => env('PUSHER_APP_SECRET'),
|
||||||
'app_id' => env('PUSHER_APP_ID'),
|
'app_id' => env('PUSHER_APP_ID'),
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||||
'useTLS' => true,
|
'port' => env('PUSHER_PORT', 443),
|
||||||
|
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||||
|
'encrypted' => true,
|
||||||
|
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||||
|
],
|
||||||
|
'client_options' => [
|
||||||
|
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ return [
|
||||||
| same cache driver to group types of items stored in your caches.
|
| same cache driver to group types of items stored in your caches.
|
||||||
|
|
|
|
||||||
| Supported drivers: "apc", "array", "database", "file",
|
| Supported drivers: "apc", "array", "database", "file",
|
||||||
| "memcached", "redis", "dynamodb", "null"
|
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -88,6 +88,10 @@ return [
|
||||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'octane' => [
|
||||||
|
'driver' => 'octane',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,12 +99,12 @@ return [
|
||||||
| Cache Key Prefix
|
| Cache Key Prefix
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| When utilizing a RAM based store such as APC or Memcached, there might
|
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||||
| be other applications utilizing the same cache. So, we'll specify a
|
| stores there might be other applications using the same cache. For
|
||||||
| value to get prefixed to all our keys so we can avoid collisions.
|
| that reason, you may prefix every cache key to avoid collisions.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"AUD", "BRL", "CAD", "CNY", "CZK", "DKK", "EUR", "HKD", "HUF", "ILS", "JPY", "MYR", "MXN", "TWD", "NZD", "NOK", "PHP", "PLN", "GBP", "RUB", "SGD", "SEK", "CHF", "THB", "USD",
|
'AUD', 'BRL', 'CAD', 'CNY', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD',
|
||||||
];
|
];
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue