Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perbaikan select epidemi penyakit #414

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -53,6 +54,7 @@ public function boot()
Schema::defaultStringLength(191);
$this->penduduk();
$this->config();
$this->blade();
}

protected function penduduk()
Expand Down Expand Up @@ -165,6 +167,13 @@ protected function config()
]);
}

protected function blade()
{
Blade::directive('selected', function ($condition) {
return "<?php if({$condition}): echo 'selected'; endif; ?>";
});
}

/**
* Register any application services.
*
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"symfony/thanks": true
}
},
"extra": {
"laravel": {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/epidemi_penyakit/form_edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="col-md-8">
<select class="form-control" id="penyakit_id" name="penyakit_id">
@foreach($jenis_penyakit as $key=>$penyakit)
<option value="{{ $key }}">{{$penyakit}}</option>
<option value="{{ $key }}" @selected($epidemi->penyakit_id === $key)>{{ $penyakit }}</option>
@endforeach
</select>
</div>
Expand Down