添加 管理员名称
This commit is contained in:
parent
9d058eb60e
commit
a30c8af278
@ -32,17 +32,16 @@ public function index(): View
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
|
||||
$request->validate([
|
||||
'email' => 'required|email|unique:admins,email',
|
||||
'name' => 'required|string|max:30',
|
||||
]);
|
||||
|
||||
// 随机密码
|
||||
$password = Str::random();
|
||||
|
||||
$admin = Admin::create([
|
||||
'email' => $request->email,
|
||||
'email' => $request->input('email'),
|
||||
'password' => bcrypt($password),
|
||||
]);
|
||||
|
||||
@ -83,6 +82,7 @@ public function update(Request $request, Admin $admin): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email|unique:admins,email,' . $admin->id,
|
||||
'name' => 'required|string|max:30',
|
||||
]);
|
||||
|
||||
$msg = '管理员信息更新成功';
|
||||
@ -98,7 +98,8 @@ public function update(Request $request, Admin $admin): RedirectResponse
|
||||
|
||||
$msg .= '。';
|
||||
|
||||
$admin->email = $request->email;
|
||||
$admin->name = $request->input('name');
|
||||
$admin->email = $request->input('email');
|
||||
|
||||
$admin->save();
|
||||
|
||||
|
@ -31,7 +31,8 @@ public function store(Request $request, WorkOrder $work_order)
|
||||
|
||||
Reply::create([
|
||||
'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', '回复成功,请等待同步。');
|
||||
|
@ -35,6 +35,7 @@ class Admin extends Authenticatable
|
||||
protected $table = 'admins';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'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')}}">
|
||||
@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">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" class="form-control" id="email" name="email" placeholder="Email" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
||||
<button type="submit" class="btn btn-primary mt-3">添加</button>
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
|
@ -1,14 +1,19 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', '管理员:' . $admin->email)
|
||||
@section('title', '管理员: ' . $admin->name)
|
||||
|
||||
@section('content')
|
||||
<h3>{{ $admin->email }}</h3>
|
||||
<h3>{{ $admin->name }}</h3>
|
||||
|
||||
<form method="POST" action="{{ route('admin.admins.update', $admin)}}">
|
||||
@csrf
|
||||
@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">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" class="form-control" id="email" name="email" value="{{ $admin->email }}">
|
||||
@ -17,7 +22,7 @@
|
||||
<div class="form-check mt-1">
|
||||
<input class="form-check-input" type="checkbox" value="1" id="reset_password" name="reset_password">
|
||||
<label class="form-check-label" for="reset_password">
|
||||
重置密码。
|
||||
重置密码
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
@ -10,27 +10,31 @@
|
||||
<div class="overflow-auto">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<th>ID</th>
|
||||
<th>邮件</th>
|
||||
<th>操作</th>
|
||||
<th>ID</th>
|
||||
<th>名称</th>
|
||||
<th>邮件</th>
|
||||
<th>操作</th>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($admins as $admin)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('admin.admins.edit', $admin) }}">
|
||||
{{ $admin->id }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ $admin->email }}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.admins.edit', $admin) }}" class="btn btn-primary btn-sm">编辑</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@foreach ($admins as $admin)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('admin.admins.edit', $admin) }}">
|
||||
{{ $admin->id }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ $admin->name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $admin->email }}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.admins.edit', $admin) }}" class="btn btn-primary btn-sm">编辑</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -38,8 +42,4 @@
|
||||
{{-- 分页 --}}
|
||||
{{ $admins->links() }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
|
@ -41,7 +41,7 @@ class="module_name"
|
||||
<a
|
||||
href="{{ route('admin.hosts.edit', $workOrder->host_id) }}"
|
||||
class="host_name"
|
||||
host="{{ $workOrder->host_id }}">
|
||||
>
|
||||
{{ $workOrder->host->name }}
|
||||
</a>
|
||||
@else
|
||||
@ -67,8 +67,4 @@ class="btn btn-primary btn-sm">编辑</a>
|
||||
{{-- 分页 --}}
|
||||
{{ $workOrders->links() }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
|
@ -24,7 +24,7 @@
|
||||
{{ $reply->name }}
|
||||
@endif
|
||||
@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')
|
||||
<a href="{{ route('admin.modules.edit', $workOrder->module_id) }}">{{ $workOrder->module->name }}
|
||||
@if ($reply->name)
|
||||
@ -61,7 +61,7 @@
|
||||
<div class="form-group">
|
||||
<label for="content">内容</label>
|
||||
<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>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-3 mb-3">提交</button>
|
||||
|
@ -86,12 +86,19 @@
|
||||
</li>
|
||||
@endif
|
||||
<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"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ Auth::guard('admin')->user()->email ?? '' }}
|
||||
{{ $admin->name ?? '管理员' }}
|
||||
</a>
|
||||
|
||||
<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') }}"
|
||||
onclick="event.preventDefault();
|
||||
document.getElementById('logout-form').submit();">
|
||||
|
@ -67,7 +67,7 @@
|
||||
|
||||
@if(Auth::guard('web')->check())
|
||||
<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
|
||||
<a class="nav-link text-auto"
|
||||
href="{{ route('admin.index') }}">切换到后台</a>
|
||||
|
Loading…
Reference in New Issue
Block a user