diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php new file mode 100644 index 0000000..35962f8 --- /dev/null +++ b/app/Http/Controllers/Admin/HomeController.php @@ -0,0 +1,18 @@ +module = $module; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|\Closure|string + */ + public function render() + { + $years = $this->module->calculate(); + return view('components.module-earning', compact('years')); + } +} diff --git a/resources/views/admin/index.blade.php b/resources/views/admin/index.blade.php index fd96372..742483c 100644 --- a/resources/views/admin/index.blade.php +++ b/resources/views/admin/index.blade.php @@ -3,7 +3,18 @@ @section('title', '首页') @section('content') +

今年的收益

- 欢迎来到后台管理系统 + @foreach($modules as $module) + @php($years = $module->calculate()) +

{{ $module->name }}

+
+ +
+ + @endforeach + + + {{ $modules->links() }} @endsection diff --git a/resources/views/admin/modules/show.blade.php b/resources/views/admin/modules/show.blade.php index 574ca99..af2abeb 100644 --- a/resources/views/admin/modules/show.blade.php +++ b/resources/views/admin/modules/show.blade.php @@ -5,31 +5,8 @@ @section('content')

{{ $module->name }}

编辑 -

收益

+

收益

- - - - - @for ($i = 1; $i < 13; $i++) - - @endfor - - - - @foreach ($years as $year => $months) - - - @for ($i = 1; $i < 13; $i++) - - - - @endfor - - @endforeach - -
年 / 月{{ $i }} 月
{{ $year }} 0) class="text-danger" @endif>{{ $months[$i]['should_balance'] ?? 0 }} - 元 -
+
@endsection diff --git a/resources/views/components/module-earning.blade.php b/resources/views/components/module-earning.blade.php new file mode 100644 index 0000000..27f7e78 --- /dev/null +++ b/resources/views/components/module-earning.blade.php @@ -0,0 +1,24 @@ + + + + + @for ($i = 1; $i < 13; $i++) + + @endfor + + + + @foreach ($years as $year => $months) + + + @for ($i = 1; $i < 13; $i++) + + + + @endfor + + @endforeach + +
年 / 月{{ $i }} 月
{{ $year }} 0) class="text-danger" @endif>{{ $months[$i]['should_balance'] ?? 0 }} + 元 +
diff --git a/routes/admin.php b/routes/admin.php index d3ef540..0bfe01b 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,6 +1,7 @@ name('logout'); - -Route::view('/', 'admin.index')->name('index')->middleware('auth:admin'); - +Route::get('/', [HomeController::class, 'index'])->name('index')->middleware('auth:admin'); Route::group([ 'middleware' => 'auth:admin',