改进 收益显示
This commit is contained in:
parent
8e14b89ffa
commit
e500341d68
18
app/Http/Controllers/Admin/HomeController.php
Normal file
18
app/Http/Controllers/Admin/HomeController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Module;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index() {
|
||||||
|
$modules = Module::paginate(10);
|
||||||
|
|
||||||
|
return view('admin.index', compact('modules'));
|
||||||
|
}
|
||||||
|
}
|
33
app/View/Components/ModuleEarning.php
Normal file
33
app/View/Components/ModuleEarning.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class ModuleEarning extends Component
|
||||||
|
{
|
||||||
|
private Module $module;
|
||||||
|
/**
|
||||||
|
* Create a new component instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Module $module)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
$this->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'));
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,18 @@
|
|||||||
@section('title', '首页')
|
@section('title', '首页')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<h2>今年的收益</h2>
|
||||||
|
|
||||||
欢迎来到后台管理系统
|
@foreach($modules as $module)
|
||||||
|
@php($years = $module->calculate())
|
||||||
|
|
||||||
|
<h3 class="mb-3">{{ $module->name }}</h3>
|
||||||
|
<div class="mt-3">
|
||||||
|
<x-module-earning :module="$module"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
|
{{ $modules->links() }}
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -5,31 +5,8 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h3>{{ $module->name }}</h3>
|
<h3>{{ $module->name }}</h3>
|
||||||
<a class="mt-3" href="{{ route('admin.modules.edit', $module) }}">编辑</a>
|
<a class="mt-3" href="{{ route('admin.modules.edit', $module) }}">编辑</a>
|
||||||
<h4>收益</h4>
|
<h4 class="mt-2">收益</h4>
|
||||||
<div>
|
<div>
|
||||||
<table class="table table-hover">
|
<x-module-earning :module="$module" />
|
||||||
<thead>
|
|
||||||
<th>年 / 月</th>
|
|
||||||
|
|
||||||
@for ($i = 1; $i < 13; $i++)
|
|
||||||
<th>{{ $i }} 月</th>
|
|
||||||
@endfor
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
@foreach ($years as $year => $months)
|
|
||||||
<tr>
|
|
||||||
<td>{{ $year }}</td>
|
|
||||||
@for ($i = 1; $i < 13; $i++)
|
|
||||||
|
|
||||||
<td @if ($months[$i]['should_balance'] ?? 0 > 0) class="text-danger" @endif>{{ $months[$i]['should_balance'] ?? 0 }}
|
|
||||||
元
|
|
||||||
</td>
|
|
||||||
|
|
||||||
@endfor
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
24
resources/views/components/module-earning.blade.php
Normal file
24
resources/views/components/module-earning.blade.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<th>年 / 月</th>
|
||||||
|
|
||||||
|
@for ($i = 1; $i < 13; $i++)
|
||||||
|
<th>{{ $i }} 月</th>
|
||||||
|
@endfor
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
@foreach ($years as $year => $months)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $year }}</td>
|
||||||
|
@for ($i = 1; $i < 13; $i++)
|
||||||
|
|
||||||
|
<td @if (($months[$i]['should_balance'] ?? 0) > 0) class="text-danger" @endif>{{ $months[$i]['should_balance'] ?? 0 }}
|
||||||
|
元
|
||||||
|
</td>
|
||||||
|
|
||||||
|
@endfor
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\Admin\AuthController;
|
use App\Http\Controllers\Admin\AuthController;
|
||||||
|
use App\Http\Controllers\Admin\HomeController;
|
||||||
use App\Http\Controllers\Admin\HostController;
|
use App\Http\Controllers\Admin\HostController;
|
||||||
use App\Http\Controllers\Admin\ModuleController;
|
use App\Http\Controllers\Admin\ModuleController;
|
||||||
use App\Http\Controllers\Admin\UserController;
|
use App\Http\Controllers\Admin\UserController;
|
||||||
@ -13,9 +14,7 @@
|
|||||||
});
|
});
|
||||||
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
|
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
|
||||||
|
|
||||||
|
Route::get('/', [HomeController::class, 'index'])->name('index')->middleware('auth:admin');
|
||||||
Route::view('/', 'admin.index')->name('index')->middleware('auth:admin');
|
|
||||||
|
|
||||||
|
|
||||||
Route::group([
|
Route::group([
|
||||||
'middleware' => 'auth:admin',
|
'middleware' => 'auth:admin',
|
||||||
|
Loading…
Reference in New Issue
Block a user