Get rid of reports page
DELETE
app/Http/Controllers/ReportsController.php
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-
-use Auth;
-use DB;
-
-class ReportsController extends Controller {
- public function get() {
- $user = Auth::user();
-
- $currentYear = date('Y');
-
- //
- $monthlyEarnings = [];
-
- for ($i = 1; $i <= 12; $i ++) {
- $monthlyEarnings[] = $user
- ->earnings()
- ->whereRaw('MONTH(date) = ?', [$i])
- ->whereRaw('YEAR(date) = ?', [$currentYear])
- ->sum('amount');
- }
-
- $monthlySpendings = [];
-
- for ($i = 1; $i <= 12; $i ++) {
- $monthlySpendings[] = $user
- ->spendings()
- ->whereRaw('MONTH(date) = ?', [$i])
- ->whereRaw('YEAR(date) = ?', [$currentYear])
- ->sum('amount');
- }
-
- //
- $tl = [];
- $tc = [];
- $td = [];
-
- foreach ($user->spendings()->whereRaw('YEAR(date)', [$currentYear])->whereNotNull('tag_id')->get() as $spending) {
- $hit = null;
-
- for ($i = 0; $i < count($tl); $i ++) {
- if ($tl[$i] == $spending->tag->name) {
- $hit = $i;
-
- break;
- }
- }
-
- if (!is_numeric($hit)) {
- $tl[] = $spending->tag->name;
- $tc[] = '#' . dechex(rand(0x000000, 0xFFFFFF));
- $td[] = $spending->amount;
- } else {
- $td[$i] += $spending->amount;
- }
- }
-
- //
- return view('reports', compact('currentYear', 'monthlyEarnings', 'monthlySpendings', 'tl', 'tc', 'td'));
- }
-}

MODIFY
resources/views/layout.blade.php
resources/views/layout.blade.php
<li>
<a href="/dashboard" {!! (Request::path() == 'dashboard') ? 'class="active"' : '' !!}><i class="fa fa-home"></i> @lang('general.dashboard')</a>
</li>
- <li>
- <a href="/reports" {!! (Request::path() == 'reports') ? 'class="active"' : '' !!}><i class="fa fa-pie-chart"></i> Reports</a>
- </li>
</ul>
<ul class="navigation__menu">
<li class="dropdown">

DELETE
resources/views/reports.blade.php
-@extends('layout')
-
-@section('title', 'Reports')
-
-@section('body')
- <div class="banner">
- <h1>Reports for {{ $currentYear }}</h1>
- </div>
- <div class="wrapper spacing-top-large spacing-bottom-large">
- <div class="row gutter">
- <div class="column">
- <div class="box">
- <div class="section">
- <canvas id="earningsSpendingsChart"></canvas>
- </div>
- </div>
- </div>
- <div class="column">
- <div class="box">
- <div class="section">
- <canvas id="tagsChart"></canvas>
- </div>
- </div>
- </div>
- </div>
- </div>
-@endsection
-
-@section('scripts')
- <script>
- var context = document.getElementById('earningsSpendingsChart').getContext('2d');
-
- var chart = new Chart(context, {
- type: 'bar',
-
- data: {
- labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
-
- datasets: [
- {
- label: 'Earnings',
- data: {!! json_encode($monthlyEarnings) !!},
- backgroundColor: 'rgba(151, 206, 86, 1)'
- }, {
- label: 'Spendings',
- data: {!! json_encode($monthlySpendings) !!},
- backgroundColor: 'rgba(255, 95, 94, 1)'
- }
- ]
- },
-
- options: {
- animation: {
- duration: 0
- },
-
- elements: {
- line: {
- tension: .2
- }
- },
-
- scales: {
- yAxes: [{ display: false }]
- }
- }
- });
-
- var context2 = document.getElementById('tagsChart').getContext('2d');
-
- var chart2 = new Chart(context2, {
- type: 'pie',
-
- data: {
- labels: {!! json_encode($tl) !!},
-
- datasets: [{
- backgroundColor: {!! json_encode($tc) !!},
- data: {!! json_encode($td) !!}
- }]
- },
-
- options: {
- animation: {
- duration: 0
- }
- }
- });
- </script>
-@endsection

MODIFY
routes/web.php
routes/web.php
@@ -32,8 +32,6 @@ Route::group(['middleware' => ['auth']], function () {
Route::patch('/tags/{tag}', 'TagsController@update')->middleware('can:update,tag');
Route::delete('/tags/{tag}', 'TagsController@destroy')->middleware('can:delete,tag');
- Route::get('/reports', 'ReportsController@get')->name('reports');
-
Route::get('/settings', 'SettingsController@index')->name('settings');
Route::post('/settings', 'SettingsController@store');
});

Get rid of reports page