Skip to content

Commit

Permalink
oke2
Browse files Browse the repository at this point in the history
  • Loading branch information
PS222407 committed Nov 2, 2022
1 parent d07bbd0 commit 3f745da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/LaravelFlashmessageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Jensramakers\LaravelFlashmessage\app\View\Components\FlashMessage;
use Jensramakers\LaravelFlashmessage\app\View\Components\form\error;

class LaravelFlashmessageServiceProvider extends ServiceProvider
{
private const PATH_VIEWS = __DIR__ . '../resources/views/';

public function register()
{
}

public function boot()
{
$this->loadViewsFrom(__DIR__ . '/resources/views/components', 'laravel-flashmessage');
$this->loadViewsFrom(__DIR__ . '/resources/views/components/form', 'laravel-flashmessage');

Blade::component(FlashMessage::class, 'flash-message');
Blade::component(error::class, 'form-error');
}
}
28 changes: 28 additions & 0 deletions src/app/View/Components/form/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Jensramakers\LaravelFlashmessage\app\View\Components\form;

use Illuminate\View\Component;

class error extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('laravel-flashmessage::form.error');
}
}
7 changes: 7 additions & 0 deletions src/resources/views/components/form/error.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@if ($errors->any())
<ul class="text-red-600">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif

0 comments on commit 3f745da

Please sign in to comment.