添加 管理员名称
This commit is contained in:
parent
9d058eb60e
commit
a30c8af278
@ -32,17 +32,16 @@ public function index(): View
|
|||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'email' => 'required|email|unique:admins,email',
|
'email' => 'required|email|unique:admins,email',
|
||||||
|
'name' => 'required|string|max:30',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 随机密码
|
// 随机密码
|
||||||
$password = Str::random();
|
$password = Str::random();
|
||||||
|
|
||||||
$admin = Admin::create([
|
$admin = Admin::create([
|
||||||
'email' => $request->email,
|
'email' => $request->input('email'),
|
||||||
'password' => bcrypt($password),
|
'password' => bcrypt($password),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -83,6 +82,7 @@ public function update(Request $request, Admin $admin): RedirectResponse
|
|||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'email' => 'required|email|unique:admins,email,' . $admin->id,
|
'email' => 'required|email|unique:admins,email,' . $admin->id,
|
||||||
|
'name' => 'required|string|max:30',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$msg = '管理员信息更新成功';
|
$msg = '管理员信息更新成功';
|
||||||
@ -98,7 +98,8 @@ public function update(Request $request, Admin $admin): RedirectResponse
|
|||||||
|
|
||||||
$msg .= '。';
|
$msg .= '。';
|
||||||
|
|
||||||
$admin->email = $request->email;
|
$admin->name = $request->input('name');
|
||||||
|
$admin->email = $request->input('email');
|
||||||
|
|
||||||
$admin->save();
|
$admin->save();
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ public function store(Request $request, WorkOrder $work_order)
|
|||||||
|
|
||||||
Reply::create([
|
Reply::create([
|
||||||
'content' => $request->input('content'),
|
'content' => $request->input('content'),
|
||||||
'work_order_id' => $work_order->id
|
'work_order_id' => $work_order->id,
|
||||||
|
'name' => auth('admin')->user()->name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return back()->with('success', '回复成功,请等待同步。');
|
return back()->with('success', '回复成功,请等待同步。');
|
||||||
|
@ -35,6 +35,7 @@ class Admin extends Authenticatable
|
|||||||
protected $table = 'admins';
|
protected $table = 'admins';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
];
|
];
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('admins', function (Blueprint $table) {
|
||||||
|
$table->string('name')->after('id')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
$admins = Admin::all();
|
||||||
|
foreach ($admins as $admin) {
|
||||||
|
$admin->name = $admin->id;
|
||||||
|
$admin->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('admins', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -9,12 +9,17 @@
|
|||||||
<form method="POST" action="{{ route('admin.admins.store')}}">
|
<form method="POST" action="{{ route('admin.admins.store')}}">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
|
<div class="form-group mt-1">
|
||||||
|
<label for="name">用户名</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" placeholder="用户名" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group mt-1">
|
<div class="form-group mt-1">
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
<input type="text" class="form-control" id="email" name="email" placeholder="Email" required>
|
<input type="text" class="form-control" id="email" name="email" placeholder="Email" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
<button type="submit" class="btn btn-primary mt-3">添加</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
@extends('layouts.admin')
|
@extends('layouts.admin')
|
||||||
|
|
||||||
@section('title', '管理员:' . $admin->email)
|
@section('title', '管理员: ' . $admin->name)
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h3>{{ $admin->email }}</h3>
|
<h3>{{ $admin->name }}</h3>
|
||||||
|
|
||||||
<form method="POST" action="{{ route('admin.admins.update', $admin)}}">
|
<form method="POST" action="{{ route('admin.admins.update', $admin)}}">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PATCH')
|
@method('PATCH')
|
||||||
|
|
||||||
|
<div class="form-group mt-1">
|
||||||
|
<label for="name">用户名</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{ $admin->name }}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group mt-1">
|
<div class="form-group mt-1">
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
<input type="text" class="form-control" id="email" name="email" value="{{ $admin->email }}">
|
<input type="text" class="form-control" id="email" name="email" value="{{ $admin->email }}">
|
||||||
@ -17,7 +22,7 @@
|
|||||||
<div class="form-check mt-1">
|
<div class="form-check mt-1">
|
||||||
<input class="form-check-input" type="checkbox" value="1" id="reset_password" name="reset_password">
|
<input class="form-check-input" type="checkbox" value="1" id="reset_password" name="reset_password">
|
||||||
<label class="form-check-label" for="reset_password">
|
<label class="form-check-label" for="reset_password">
|
||||||
重置密码。
|
重置密码
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -10,27 +10,31 @@
|
|||||||
<div class="overflow-auto">
|
<div class="overflow-auto">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>邮件</th>
|
<th>名称</th>
|
||||||
<th>操作</th>
|
<th>邮件</th>
|
||||||
|
<th>操作</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($admins as $admin)
|
@foreach ($admins as $admin)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('admin.admins.edit', $admin) }}">
|
<a href="{{ route('admin.admins.edit', $admin) }}">
|
||||||
{{ $admin->id }}
|
{{ $admin->id }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ $admin->email }}
|
{{ $admin->name }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('admin.admins.edit', $admin) }}" class="btn btn-primary btn-sm">编辑</a>
|
{{ $admin->email }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td>
|
||||||
@endforeach
|
<a href="{{ route('admin.admins.edit', $admin) }}" class="btn btn-primary btn-sm">编辑</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -38,8 +42,4 @@
|
|||||||
{{-- 分页 --}}
|
{{-- 分页 --}}
|
||||||
{{ $admins->links() }}
|
{{ $admins->links() }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -41,7 +41,7 @@ class="module_name"
|
|||||||
<a
|
<a
|
||||||
href="{{ route('admin.hosts.edit', $workOrder->host_id) }}"
|
href="{{ route('admin.hosts.edit', $workOrder->host_id) }}"
|
||||||
class="host_name"
|
class="host_name"
|
||||||
host="{{ $workOrder->host_id }}">
|
>
|
||||||
{{ $workOrder->host->name }}
|
{{ $workOrder->host->name }}
|
||||||
</a>
|
</a>
|
||||||
@else
|
@else
|
||||||
@ -67,8 +67,4 @@ class="btn btn-primary btn-sm">编辑</a>
|
|||||||
{{-- 分页 --}}
|
{{-- 分页 --}}
|
||||||
{{ $workOrders->links() }}
|
{{ $workOrders->links() }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
{{ $reply->name }}
|
{{ $reply->name }}
|
||||||
@endif
|
@endif
|
||||||
@elseif ($reply->role === 'admin')
|
@elseif ($reply->role === 'admin')
|
||||||
<span class="text-primary">{{ config('app.display_name') }}</span>
|
<span class="text-primary">{{ config('app.display_name') }} 的 {{ $reply->name }}</span>
|
||||||
@elseif ($reply->role === 'module')
|
@elseif ($reply->role === 'module')
|
||||||
<a href="{{ route('admin.modules.edit', $workOrder->module_id) }}">{{ $workOrder->module->name }}
|
<a href="{{ route('admin.modules.edit', $workOrder->module_id) }}">{{ $workOrder->module->name }}
|
||||||
@if ($reply->name)
|
@if ($reply->name)
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="content">内容</label>
|
<label for="content">内容</label>
|
||||||
<textarea class="form-control" id="content" name="content" rows="10"
|
<textarea class="form-control" id="content" name="content" rows="10"
|
||||||
placeholder="作为 {{ config('app.display_name') }} 回复。"></textarea>
|
placeholder="作为 {{ config('app.display_name') }} 的 {{ Auth::guard('admin')->user()->name }} 回复。"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary mt-3 mb-3">提交</button>
|
<button type="submit" class="btn btn-primary mt-3 mb-3">提交</button>
|
||||||
|
@ -86,12 +86,19 @@
|
|||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
|
|
||||||
|
@php($admin = \Illuminate\Support\Facades\Auth::guard('admin')->user())
|
||||||
|
|
||||||
<a id="navbarDropdown" class="nav-link dropdown-toggle text-auto" href="#" role="button"
|
<a id="navbarDropdown" class="nav-link dropdown-toggle text-auto" href="#" role="button"
|
||||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
{{ Auth::guard('admin')->user()->email ?? '' }}
|
{{ $admin->name ?? '管理员' }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="{{ route('admin.admins.edit', $admin) }}">
|
||||||
|
编辑资料
|
||||||
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item" href="{{ route('admin.logout') }}"
|
<a class="dropdown-item" href="{{ route('admin.logout') }}"
|
||||||
onclick="event.preventDefault();
|
onclick="event.preventDefault();
|
||||||
document.getElementById('logout-form').submit();">
|
document.getElementById('logout-form').submit();">
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
@if(Auth::guard('web')->check())
|
@if(Auth::guard('web')->check())
|
||||||
<a class="nav-link text-auto"
|
<a class="nav-link text-auto"
|
||||||
href="{{ route('admin.users.edit', Auth::guard('web')->id()) }}">返回到后台</a>
|
href="{{ route('admin.users.edit', Auth::guard('web')->id()) }}">回到 {{ Auth::guard('admin')->user()->name }}</a>
|
||||||
@else
|
@else
|
||||||
<a class="nav-link text-auto"
|
<a class="nav-link text-auto"
|
||||||
href="{{ route('admin.index') }}">切换到后台</a>
|
href="{{ route('admin.index') }}">切换到后台</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user