增加 工单角色
This commit is contained in:
parent
e4b8eeb312
commit
3a19269ab6
@ -70,6 +70,7 @@ class Reply extends Model
|
||||
'name',
|
||||
'module_id',
|
||||
'is_pending',
|
||||
'role'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
@ -88,19 +89,27 @@ protected static function boot()
|
||||
|
||||
throw_if($model->workOrder->isFailure(), CommonException::class, '工单还没有就绪。');
|
||||
|
||||
|
||||
// change work order status
|
||||
if (auth('sanctum')->check()) {
|
||||
$model->user_id = auth()->id();
|
||||
$model->user_id = auth('sanctum')->id();
|
||||
$model->role = 'user';
|
||||
$model->workOrder->status = 'user_replied';
|
||||
}
|
||||
|
||||
if (auth('module')->check() || auth('admin')->check()) {
|
||||
} else if (auth('module')->check()) {
|
||||
$model->user_id = null;
|
||||
$model->role = 'module';
|
||||
$model->workOrder->status = 'replied';
|
||||
|
||||
broadcast(new UserEvent($model->user_id, 'work-order.replied', $model->workOrder));
|
||||
|
||||
} else if (auth('admin')->check()) {
|
||||
$model->role = 'admin';
|
||||
} else {
|
||||
$model->role = 'guest';
|
||||
}
|
||||
|
||||
|
||||
$model->workOrder->save();
|
||||
});
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
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('work_order_replies', function (Blueprint $table) {
|
||||
$table->string('role')->default('user')->comment('回复角色')->after('module_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('work_order_replies', function (Blueprint $table) {
|
||||
$table->dropColumn('role');
|
||||
});
|
||||
}
|
||||
};
|
@ -15,17 +15,21 @@
|
||||
@foreach($replies as $reply)
|
||||
<div class="card border-light mb-3 shadow">
|
||||
<div class="card-header d-flex w-100 justify-content-between">
|
||||
@if ($reply->role === 'user')
|
||||
@if ($reply->user_id)
|
||||
<a href="{{ route('admin.users.edit', $reply->user) }}">{{ $workOrder->user->name }}</a>
|
||||
@elseif($reply->module_id)
|
||||
@else
|
||||
{{ $reply->name }}
|
||||
@endif
|
||||
@elseif ($reply->role === 'admin')
|
||||
<span class="text-primary">{{ config('app.display_name') }}</span>
|
||||
@elseif ($reply->role === 'module')
|
||||
<a href="{{ route('admin.modules.edit', $workOrder->module_id) }}">{{ $workOrder->module->name }}
|
||||
@if ($reply->name)
|
||||
的 {{ $reply->name }}
|
||||
@endif
|
||||
</a>
|
||||
@elseif ($reply->name === null && $reply->user_id === null && $reply->module_id === null)
|
||||
<span class="text-primary">{{ config('app.display_name') }}</span>
|
||||
@else
|
||||
@elseif ($reply->role === 'guest')
|
||||
{{ $reply->name }}
|
||||
@endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user