WIP: Road to 1.0.0 #1

Draft
miguel456 wants to merge 123 commits from develop into master
6 changed files with 168 additions and 0 deletions
Showing only changes of commit 6d94263ede - Show all commits

View File

@ -146,6 +146,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" /> <excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" /> <excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" />
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" /> <excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/sanctum" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View File

@ -153,6 +153,7 @@
<path value="$PROJECT_DIR$/vendor/awssat/discord-notification-channel" /> <path value="$PROJECT_DIR$/vendor/awssat/discord-notification-channel" />
<path value="$PROJECT_DIR$/vendor/berkayk/onesignal-laravel" /> <path value="$PROJECT_DIR$/vendor/berkayk/onesignal-laravel" />
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" /> <path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
<path value="$PROJECT_DIR$/vendor/laravel/sanctum" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" /> <component name="PhpProjectSharedConfiguration" php_language_level="7.3" />

17
app/Facades/JSON.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class JSON extends Facade
{
protected static function getFacadeAccessor()
{
return 'json';
}
}

116
app/Helpers/JSON.php Normal file
View File

@ -0,0 +1,116 @@
<?php
namespace App\Helpers;
/**
* Class JSON - Used for JSON responses.
* @package App\Helpers
*/
class JSON
{
protected $type, $status, $message, $code, $data;
/**
* @param mixed $type
*/
public function setResponseType($type): JSON
{
$this->type = $type;
return $this;
}
/**
* @return mixed
*/
public function getType()
{
return $this->type;
}
/**
* @return mixed
*/
public function getStatus()
{
return $this->status;
}
/**
* @param mixed $status
* @return JSON
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* @return mixed
*/
public function getMessage()
{
return $this->message;
}
/**
* @param mixed $message
* @return JSON
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}
/**
* @return mixed
*/
public function getCode()
{
return $this->code;
}
/**
* @param mixed $code
* @return JSON
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* @return mixed
*/
public function getData()
{
return $this->data;
}
/**
* @param mixed $data
* @return JSON
*/
public function setData($data)
{
$this->data = $data;
return $this;
}
public function build($headers = [])
{
$response = [
'status' => $this->getStatus(),
'message' => $this->getMessage(),
'type' => $this->getType(),
'response' => $this->getData()
];
return response($response, $this->getCode(), $headers);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Providers;
use App\Helpers\JSON;
use Illuminate\Support\ServiceProvider;
class JSONProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
App::bind('json', function () {
return new JSON();
});
}
}

View File

@ -244,6 +244,7 @@ return [
\App\Providers\MojangStatusProvider::class, \App\Providers\MojangStatusProvider::class,
\App\Providers\OptionsProvider::class, \App\Providers\OptionsProvider::class,
App\Providers\DigitalStorageProvider::class, App\Providers\DigitalStorageProvider::class,
App\Providers\JSONProvider::class,
], ],
@ -301,6 +302,7 @@ return [
'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class, 'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class,
'ContextAwareValidator' => App\Facades\ContextAwareValidation::class, 'ContextAwareValidator' => App\Facades\ContextAwareValidation::class,
'Settings' => App\Facades\Options::class, 'Settings' => App\Facades\Options::class,
'JSON' => App\Facades\JSON::class
], ],