Skip to main content

guillaumebriday/laravel-blog

1798 stars
3 code files
View guillaumebriday/laravel-blog on GitHub

app/View/Components/Alert.php

Open in GitHub
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');
}
}

resources/views/shared/alerts.blade.php

Open in GitHub
@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

resources/views/comments/_form.blade.php

Open in GitHub
@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

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.