改进 关联显示

This commit is contained in:
iVampireSP.com 2022-11-20 11:56:48 +08:00
parent e500341d68
commit 0b33aef582
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
4 changed files with 63 additions and 3 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Host;
use App\Models\Module;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@ -86,7 +87,9 @@ public function show(Module $module): View
{
$years = $module->calculate();
return view('admin.modules.show', compact('module', 'years'));
$hosts = Host::where('module_id', $module->id)->latest()->paginate(50);
return view('admin.modules.show', compact('module', 'years', 'hosts'));
}
/**

View File

@ -25,7 +25,7 @@
</a>
</td>
<td>
<a href="{{ route('admin.hosts.edit', $host) }}" class="module_name"
<a href="{{ route('admin.modules.show', $host->module_id) }}" class="module_name"
module="{{ $host->module_id }}">{{ $host->module_id }}</a>
</td>
<td>

View File

@ -7,6 +7,51 @@
<a class="mt-3" href="{{ route('admin.modules.edit', $module) }}">编辑</a>
<h4 class="mt-2">收益</h4>
<div>
<x-module-earning :module="$module" />
<x-module-earning :module="$module"/>
</div>
<h4 class="mt-2">主机</h4>
<div class="overflow-auto">
<table class="table table-hover">
<thead>
<th>ID</th>
<th>名称</th>
<th>用户</th>
<th>创建时间</th>
<th>更新时间</th>
<th>操作</th>
</thead>
<tbody>
@foreach ($hosts as $host)
<tr>
<td>
<a href="{{ route('admin.hosts.edit', $host) }}">
{{ $host->id }}
</a>
</td>
<td>
{{ $host->name }}
</td>
<td>
<a href="{{ route('admin.users.edit', $host->user_id) }}"> {{ $host->user->name }}</a>
</td>
<td>
{{ $host->created_at }}
</td>
<td>
{{ $host->updated_at }}
</td>
<td>
<a href="{{ route('admin.hosts.edit', $host) }}" class="btn btn-primary btn-sm">编辑</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
{{-- 分页 --}}
{{ $hosts->links() }}
@endsection

View File

@ -10,6 +10,7 @@
<th>ID</th>
<th>标题</th>
<th>模块</th>
<th>主机</th>
<th>发起者</th>
<th>状态</th>
<th>操作</th>
@ -35,6 +36,17 @@ class="module_name"
module="{{ $workOrder->module_id }}">{{ $workOrder->module_id }}
</a>
</td>
<td>
@if ($workOrder->host_id)
<a
href="{{ route('admin.hosts.edit', $workOrder->host_id) }}"
class="host_name"
host="{{ $workOrder->host_id }}">{{ $workOrder->host_id }}
</a>
@else
@endif
</td>
<td>
<a href="{{ route('admin.users.edit', $workOrder->user_id) }}">{{ $workOrder->user->name }}</a>
</td>