Code cleanup

This commit is contained in:
James Cole
2021-03-21 09:15:40 +01:00
parent da1751940e
commit 206845575c
317 changed files with 7418 additions and 7362 deletions

View File

@@ -38,30 +38,6 @@ trait FormSupport
{
/**
* @return AccountRepositoryInterface
*/
protected function getAccountRepository(): AccountRepositoryInterface
{
return app(AccountRepositoryInterface::class);
}
/**
* @return Carbon
*/
protected function getDate(): Carbon
{
/** @var Carbon $date */
$date = null;
try {
$date = today(config('app.timezone'));
} catch (Exception $e) {
$e->getMessage();
}
return $date;
}
/**
* @param string $name
* @param array $list
@@ -88,6 +64,23 @@ trait FormSupport
return $html;
}
/**
* @param $name
* @param $options
*
* @return string
*/
protected function label(string $name, array $options = null): string
{
$options = $options ?? [];
if (isset($options['label'])) {
return $options['label'];
}
$name = str_replace('[]', '', $name);
return (string)trans('form.' . $name);
}
/**
* @param $name
* @param $label
@@ -107,6 +100,25 @@ trait FormSupport
return $options;
}
/**
* @param $name
*
* @return string
*/
protected function getHolderClasses(string $name): string
{
// Get errors from session:
/** @var MessageBag $errors */
$errors = session('errors');
$classes = 'form-group';
if (null !== $errors && $errors->has($name)) {
$classes = 'form-group has-error has-feedback';
}
return $classes;
}
/**
* @param string $name
* @param $value
@@ -137,38 +149,26 @@ trait FormSupport
}
/**
* @param $name
*
* @return string
* @return AccountRepositoryInterface
*/
protected function getHolderClasses(string $name): string
protected function getAccountRepository(): AccountRepositoryInterface
{
// Get errors from session:
/** @var MessageBag $errors */
$errors = session('errors');
$classes = 'form-group';
if (null !== $errors && $errors->has($name)) {
$classes = 'form-group has-error has-feedback';
}
return $classes;
return app(AccountRepositoryInterface::class);
}
/**
* @param $name
* @param $options
*
* @return string
* @return Carbon
*/
protected function label(string $name, array $options = null): string
protected function getDate(): Carbon
{
$options = $options ?? [];
if (isset($options['label'])) {
return $options['label'];
/** @var Carbon $date */
$date = null;
try {
$date = today(config('app.timezone'));
} catch (Exception $e) {
$e->getMessage();
}
$name = str_replace('[]', '', $name);
return (string)trans('form.' . $name);
return $date;
}
}