优化错误显示

This commit is contained in:
pushuo 2022-08-19 18:53:24 +08:00
parent 2e989a3382
commit d6eee750ec
6 changed files with 8 additions and 9 deletions

View File

@ -9,9 +9,9 @@ class Alert extends Component
public string $type;
public string $msg;
public function __construct(string $type, string $msg)
public function __construct(?string $type = 'success', string $msg)
{
$this->type = $type;
$this->type = $type ?? 'success';
$this->msg = $msg;
}

View File

@ -9,9 +9,9 @@ class Alert extends Component
public string $type;
public string $msg;
public function __construct(string $type, string $msg)
public function __construct(?string $type = 'success', string $msg)
{
$this->type = $type;
$this->type = $type ?? 'success';
$this->msg = $msg;
}

View File

@ -1,4 +1,4 @@
<div class="alert alert-success alert-dismissible">
<div class="alert alert-{{ $type }} alert-dismissible">
<i class="bi bi-check-circle-fill"></i>
{{ $msg }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>

View File

@ -5,7 +5,7 @@
@section('content')
@if ($errors->has('error'))
<x-admin-alert type="Danger" msg="{{ $errors->has('error') }}" class="mt-4" />
<x-admin-alert type="danger" msg="{{ $errors->has('error') }}" class="mt-4" />
@endif
<div class="card">

View File

@ -17,9 +17,8 @@
<div class="col-12 col-md-9">@include('shared.steps', ['steps' => 1])</div>
</div>
{{-- @dump($errors) --}}
@if ($errors->has('error'))
<x-admin-alert type="Danger" msg="{{ $errors->has('error') }}" class="mt-4" />
<x-shop-alert type="danger" msg="{{ $errors->has('error') }}" class="mt-4" />
@endif
<div class="row mt-5" v-if="products.length">

View File

@ -1,4 +1,4 @@
<div class="alert alert-success alert-dismissible">
<div class="alert alert-{{ $type }} alert-dismissible">
<i class="bi bi-check-circle-fill"></i>
{{ $msg }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>