Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

jcergolj/laravellte

216 stars
3 code files
View jcergolj/laravellte on GitHub

app/Providers/AppServiceProvider.php

Open in GitHub
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
 
class AppServiceProvider extends ServiceProvider
{
//
public function register()
{
Blade::directive('errorClass', function ($field) {
$ifStatement = "if(session()->has('errors') && session('errors')->has(${field}))";
 
return "<?php {$ifStatement} echo 'is-invalid'; ?>";
});
}
//
}

resources/views/components/inputs/text.blade.php

Open in GitHub
@props(['key'])
 
<div class="input-group mb-3">
<input
{{ $attributes }}
wire:model.defer="{{ $key }}"
type="text"
name="{{ $key }}"
class="form-control @errorClass($key)"
placeholder="{{ trans("validation.attributes.$key") }}"
>
 
<x-inputs.fa fontAwesome="fa-edit" />
 
<x-inputs.error field="{{ $key }}" />
</div>

resources/views/components/inputs/dropdown.blade.php

Open in GitHub
@props(['options', 'key', 'textField'])
 
<div class="input-group mb-3">
<select
{{ $attributes }}
wire:model.defer="{{ $key }}"
name="{{ $key }}"
class="form-control @errorClass($key)"
value="{{ old($key) }}"
placeholder="{{ trans("validation.attributes.$key") }}"
>
<option value="">-- select --</option>
@foreach($options as $option)
<option value="{{ $option->id }}">{{ $option->$textField }}</option>
@endforeach
</select>
 
<x-inputs.fa fontAwesome="fa-cogs" />
 
<x-inputs.error field="{{ $key }}" />
</div>

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.