diff --git a/app/Entities/Pages/PagesRepository.php b/app/Entities/Pages/PagesRepository.php deleted file mode 100755 index eac4b03..0000000 --- a/app/Entities/Pages/PagesRepository.php +++ /dev/null @@ -1,28 +0,0 @@ -model = $model; - } - - public function getTotalIncome() - { - return Payment::whereType(1)->sum('amount'); - } - - public function getTotalExpenditure() - { - return Payment::whereType(0)->sum('amount'); - } -} \ No newline at end of file diff --git a/app/Entities/Projects/Status.php b/app/Entities/Projects/Status.php index 0b31ea0..a66c80a 100644 --- a/app/Entities/Projects/Status.php +++ b/app/Entities/Projects/Status.php @@ -3,6 +3,7 @@ namespace App\Entities\Projects; use App\Entities\ReferenceAbstract; +use App\Exceptions\ReferenceKeyNotFoundException; class Status extends ReferenceAbstract { @@ -15,9 +16,36 @@ class Status extends ReferenceAbstract 6 => 'on_hold', ]; + protected static $colors = [ + 1 => 'default', + 2 => 'yellow', + 3 => 'primary', + 4 => 'green', + 5 => 'danger', + 6 => 'warning', + ]; + + protected static $icons = [ + 1 => 'paperclip', + 2 => 'tasks', + 3 => 'thumbs-o-up', + 4 => 'money', + 5 => 'frown-o', + 6 => 'hand-paper-o', + ]; + public static function getNameById($singleId) { - return trans('project.'.static::$lists[$singleId]); + return trans('project.'.static::getById($singleId)); + } + + public static function getIconById($singleId) + { + if ( ! ! static::getById($singleId) && isset(static::$icons[$singleId])) { + return static::$icons[$singleId]; + } + + throw new ReferenceKeyNotFoundException('Reference key: '.$singleId.' not found for '.get_called_class().'::icons'); } public static function toArray() @@ -29,9 +57,4 @@ class Status extends ReferenceAbstract return $lists; } - - public static function all() - { - return collect($this->toArray()); - } } diff --git a/app/Entities/ReferenceAbstract.php b/app/Entities/ReferenceAbstract.php index a5202dc..3a9ac26 100644 --- a/app/Entities/ReferenceAbstract.php +++ b/app/Entities/ReferenceAbstract.php @@ -2,6 +2,7 @@ namespace App\Entities; +use App\Exceptions\ReferenceKeyNotFoundException; use Illuminate\Support\Arr; abstract class ReferenceAbstract @@ -27,7 +28,11 @@ abstract class ReferenceAbstract public static function getById($singleId) { - return static::$lists[$singleId]; + if (isset(static::$lists[$singleId])) { + return static::$lists[$singleId]; + } + + new ReferenceKeyNotFoundException('Reference key: '.$singleId.' not found for '.get_called_class().'::lists'); } public static function only(array $singleIds) @@ -47,7 +52,11 @@ abstract class ReferenceAbstract public static function getColorById($colorId) { - return isset(static::$lists[$colorId]) ? static::$colors[$colorId] : null; + if ( ! ! static::getById($colorId) && isset(static::$colors[$colorId])) { + return static::$colors[$colorId]; + } + + throw new ReferenceKeyNotFoundException('Reference key: '.$colorId.' not found for '.get_called_class().'::colors'); } public static function colorsExcept(array $colorIds) diff --git a/app/Exceptions/ReferenceKeyNotFoundException.php b/app/Exceptions/ReferenceKeyNotFoundException.php new file mode 100644 index 0000000..400a141 --- /dev/null +++ b/app/Exceptions/ReferenceKeyNotFoundException.php @@ -0,0 +1,9 @@ +repo = $repo; - } - +class PagesController extends Controller +{ public function home() { - $projectsCount = Project::select(DB::raw('status_id, count(id) as count')) - ->groupBy('status_id') - ->where('owner_id', auth()->id()) - ->pluck('count','status_id') - ->all(); - return view('pages.home', compact('projectsCount')); + return view('pages.home'); } public function about() { return view('pages.about'); - } + } } diff --git a/app/Http/Middleware/GlobalViewVariables.php b/app/Http/Middleware/GlobalViewVariables.php index d7e477b..dbdebd8 100644 --- a/app/Http/Middleware/GlobalViewVariables.php +++ b/app/Http/Middleware/GlobalViewVariables.php @@ -22,7 +22,7 @@ class GlobalViewVariables ->pluck('count', 'status_id') ->all(); - view()->share('sidebarProjectStats', $projectsCount); + view()->share('projectStatusStats', $projectsCount); return $next($request); } diff --git a/resources/views/pages/home.blade.php b/resources/views/pages/home.blade.php index 4d9e585..13aae94 100755 --- a/resources/views/pages/home.blade.php +++ b/resources/views/pages/home.blade.php @@ -7,59 +7,71 @@ @section('content-dashboard')
-
- @include('view-components.dashboard-panel', [ - 'class' => 'default', - 'icon' => 'paperclip', - 'number' => array_key_exists(1, $projectsCount) ? $projectsCount[1] : 0, - 'text' => $projectStatuses::getNameById(1), - 'linkRoute' => route('projects.index', ['status' => 1]), - ]) +
+ Project Status Stats +
+ @foreach($projectStatuses::all() as $statusId => $status) + @if ($statusId == 4) +
+ @endif +
+ @include('view-components.dashboard-panel', [ + 'class' => $projectStatuses->getColorById($statusId), + 'icon' => $projectStatuses->getIconById($statusId), + 'number' => array_key_exists($statusId, $projectStatusStats) ? $projectStatusStats[$statusId] : 0, + 'text' => $projectStatuses::getNameById($statusId), + 'linkRoute' => route('projects.index', ['status' => $statusId]), + ]) +
+ @if ($statusId == 3) +
+ @endif + @endforeach +
-
- @include('view-components.dashboard-panel', [ - 'class' => 'yellow', - 'icon' => 'tasks', - 'number' => array_key_exists(2, $projectsCount) ? $projectsCount[2] : 0, - 'text' => $projectStatuses::getNameById(2), - 'linkRoute' => route('projects.index', ['status' => 2]), - ]) -
-
- @include('view-components.dashboard-panel', [ - 'class' => 'primary', - 'icon' => 'thumbs-o-up', - 'number' => array_key_exists(3, $projectsCount) ? $projectsCount[3] : 0, - 'text' => $projectStatuses::getNameById(3), - 'linkRoute' => route('projects.index', ['status' => 3]), - ]) -
-
- @include('view-components.dashboard-panel', [ - 'class' => 'green', - 'icon' => 'money', - 'number' => array_key_exists(4, $projectsCount) ? $projectsCount[4] : 0, - 'text' => $projectStatuses::getNameById(4), - 'linkRoute' => route('projects.index', ['status' => 4]), - ]) -
-
- @include('view-components.dashboard-panel', [ - 'class' => 'danger', - 'icon' => 'frown-o', - 'number' => array_key_exists(5, $projectsCount) ? $projectsCount[5] : 0, - 'text' => $projectStatuses::getNameById(5), - 'linkRoute' => route('projects.index', ['status' => 5]), - ]) -
-
- @include('view-components.dashboard-panel', [ - 'class' => 'warning', - 'icon' => 'hand-paper-o', - 'number' => array_key_exists(6, $projectsCount) ? $projectsCount[6] : 0, - 'text' => $projectStatuses::getNameById(6), - 'linkRoute' => route('projects.index', ['status' => 6]), - ]) +
+ Earnings Stats + + +
    +
  • Earnings (2017) {{ formatRp(1000000) }}
  • +
  • Finished Project (2017) 0 Projects
  • +
  • Receiveable Earnings {{ formatRp(1000000) }}
  • +
+ + Upcoming Subscriptions Due Dates + +
+ + + + + + + + @foreach(range(1, 4) as $subscription) + + + + + + + @endforeach +
ProjectItemsTagihanDue Date
Project {{ $subscription }}Hosting & Domain{{ formatRp(rand(1, 3).'000000') }}2017-12-01
+
@endsection diff --git a/resources/views/view-components/dashboard-panel.blade.php b/resources/views/view-components/dashboard-panel.blade.php index d08af47..9c897fa 100644 --- a/resources/views/view-components/dashboard-panel.blade.php +++ b/resources/views/view-components/dashboard-panel.blade.php @@ -9,16 +9,16 @@ $linkRoute = isset($linkRoute) ? $linkRoute : '#';
-
+
-
-
-
{{ $number }}
+
+
+
{{ $number }}
{{ $text }}
- diff --git a/resources/views/view-components/sidebar-project-list-links.blade.php b/resources/views/view-components/sidebar-project-list-links.blade.php index 27e8f14..e751b60 100644 --- a/resources/views/view-components/sidebar-project-list-links.blade.php +++ b/resources/views/view-components/sidebar-project-list-links.blade.php @@ -1,12 +1,12 @@ @inject('projectStatuses', 'App\Entities\Projects\Status')