Code cleanup [skip ci]

This commit is contained in:
James Cole
2020-10-18 08:01:10 +02:00
parent b8774a7af3
commit 2630732b8a
16 changed files with 117 additions and 120 deletions

View File

@@ -44,9 +44,8 @@ abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
protected ParameterBag $parameters;
protected const CONTENT_TYPE = 'application/vnd.api+json';
protected ParameterBag $parameters;
/**
* Controller constructor.
@@ -66,43 +65,6 @@ abstract class Controller extends BaseController
}
/**
* Method to help build URI's.
*
* @return string
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
$return .= http_build_query($params);
return $return;
}
/**
* @return Manager
*/
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager;
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
/**
* Method to grab all parameters from the URI.
*
@@ -145,4 +107,41 @@ abstract class Controller extends BaseController
return $bag;
}
/**
* Method to help build URI's.
*
* @return string
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
$return .= http_build_query($params);
return $return;
}
/**
* @return Manager
*/
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager;
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
}