Switch should have default thing.

This commit is contained in:
James Cole
2020-10-03 17:53:23 +02:00
parent b8e36b0398
commit 61ffc8ada6
7 changed files with 16 additions and 4 deletions

View File

@@ -56,6 +56,8 @@ class ConfigurationRequest extends FormRequest
{ {
$name = $this->route()->parameter('configName'); $name = $this->route()->parameter('configName');
switch ($name) { switch ($name) {
default:
break;
case 'is_demo_site': case 'is_demo_site':
case 'single_user_mode': case 'single_user_mode':
return ['value' => $this->boolean('value')]; return ['value' => $this->boolean('value')];
@@ -75,6 +77,8 @@ class ConfigurationRequest extends FormRequest
{ {
$name = $this->route()->parameter('configName'); $name = $this->route()->parameter('configName');
switch ($name) { switch ($name) {
default:
break;
case 'is_demo_site': case 'is_demo_site':
case 'single_user_mode': case 'single_user_mode':
return ['value' => ['required', new IsBoolean]]; return ['value' => ['required', new IsBoolean]];

View File

@@ -128,6 +128,8 @@ class OtherCurrenciesCorrections extends Command
/** @var Transaction $lead */ /** @var Transaction $lead */
$lead = null; $lead = null;
switch ($journal->transactionType->type) { switch ($journal->transactionType->type) {
default:
break;
case TransactionType::WITHDRAWAL: case TransactionType::WITHDRAWAL:
$lead = $journal->transactions()->where('amount', '<', 0)->first(); $lead = $journal->transactions()->where('amount', '<', 0)->first();
break; break;

View File

@@ -587,6 +587,8 @@ class AccountController extends Controller
$entries = []; $entries = [];
$current = clone $start; $current = clone $start;
switch ($step) { switch ($step) {
default:
break;
case '1D': case '1D':
// per day the entire period, balance for every day. // per day the entire period, balance for every day.
$format = (string) trans('config.month_and_day', [], $locale); $format = (string) trans('config.month_and_day', [], $locale);

View File

@@ -103,8 +103,8 @@ class RecurrenceController extends Controller
$repetition->repetition_skip = (int) $request->get('skip'); $repetition->repetition_skip = (int) $request->get('skip');
$repetition->weekend = (int) $request->get('weekend'); $repetition->weekend = (int) $request->get('weekend');
$actualEnd = clone $end; $actualEnd = clone $end;
$occurrences = [];
switch ($endsAt) { switch ($endsAt) {
default:
case 'forever': case 'forever':
// simply generate up until $end. No change from default behavior. // simply generate up until $end. No change from default behavior.
$occurrences = $this->recurring->getOccurrencesInRange($repetition, $actualStart, $actualEnd); $occurrences = $this->recurring->getOccurrencesInRange($repetition, $actualStart, $actualEnd);

View File

@@ -384,12 +384,13 @@ class ReportController extends Controller
} }
switch ($reportType) { switch ($reportType) {
case 'category': default:
$uri = route('reports.report.category', [$accounts, $categories, $start, $end]);
break;
case 'default': case 'default':
$uri = route('reports.report.default', [$accounts, $start, $end]); $uri = route('reports.report.default', [$accounts, $start, $end]);
break; break;
case 'category':
$uri = route('reports.report.category', [$accounts, $categories, $start, $end]);
break;
case 'audit': case 'audit':
$uri = route('reports.report.audit', [$accounts, $start, $end]); $uri = route('reports.report.audit', [$accounts, $start, $end]);
break; break;

View File

@@ -73,6 +73,7 @@ class AccountSearch implements GenericSearchInterface
$like = sprintf('%%%s%%', $this->query); $like = sprintf('%%%s%%', $this->query);
$originalQuery = $this->query; $originalQuery = $this->query;
switch ($this->field) { switch ($this->field) {
default:
case self::SEARCH_ALL: case self::SEARCH_ALL:
$query->where( $query->where(
static function (Builder $q) use ($like) { static function (Builder $q) use ($like) {

View File

@@ -354,6 +354,7 @@ trait TransactionValidation
$sources = array_unique($sources); $sources = array_unique($sources);
$dests = array_unique($dests); $dests = array_unique($dests);
switch ($type) { switch ($type) {
default:
case 'withdrawal': case 'withdrawal':
if (count($sources) > 1) { if (count($sources) > 1) {
$validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));
@@ -409,6 +410,7 @@ trait TransactionValidation
} }
// TODO not the best way to loop this. // TODO not the best way to loop this.
switch ($type) { switch ($type) {
default:
case 'withdrawal': case 'withdrawal':
if ($this->arrayEqual($comparison['source_id'])) { if ($this->arrayEqual($comparison['source_id'])) {
// source ID's are equal, return void. // source ID's are equal, return void.