use Illuminate\View\Component;
use Illuminate\View\View;
class Alert extends Component
{
public string $type;
public ?string $dismissible;
public function __construct(string $type, string $dismissible = null)
{
$this->type = $type;
$this->dismissible = $dismissible;
}
public function render(): View
{
return view('components.alert');
}
}
@if (Session::has('success'))
<x-alert type="success" :dismissible="true">
{{ Session::get('success') }}
</x-alert>
@endif
@if (Session::has('errors'))
<x-alert type="danger" :dismissible="true">
@if ($errors->count() > 1)
{{ trans_choice('validation.errors', $errors->count()) }}
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@else
{{ $errors->first() }}
@endif
</x-alert>
@endif
@auth
<comment-form
:post-id="{{ $post->id }}"
placeholder="@lang('comments.placeholder.content')"
button="@lang('comments.comment')">
</comment-form>
@else
<x-alert type="warning">
@lang('comments.sign_in_to_comment')
</x-alert>
@endauth
Additional resources on blade components:
-
Povilas Korop | www.youtube.com
Published on
-
Povilas Korop | www.youtube.com
Published on
-
Blade components for your layout
Article
Marcel Pociot | beyondco.de
Published on
-
Article
Eric The Coder | dev.to
Published on