add period

pull/1/head
Aji Kamaludin 6 years ago
parent 814d0a9902
commit 4e1cf65519
No known key found for this signature in database
GPG Key ID: 23E2BDC458317AF8

@ -36,7 +36,6 @@ class PeriodeController extends Controller
*/
public function store(Request $request)
{
//validate
$request->validate([
'nama' => 'required|max:255',
'tgl_mulai' => 'required|date|before:'.$request->tgl_selesai,
@ -44,9 +43,22 @@ class PeriodeController extends Controller
'is_active' => 'nullable|boolean',
]);
//input
if(Periode::create($request->input())){
$periode = Periode::make($request->input());
if($request->is_active == null){
$periode->is_active = 0;
}
if($periode->save()){
return redirect()->route('periode.index')->with([
'type' => 'success',
'msg' => 'Periode baru ditambahkan'
]);
}else{
return redirect()->route('periode.index')->with([
'type' => 'danger',
'msg' => 'Err.., Terjadi Kesalahan'
]);
}
}

@ -11,7 +11,8 @@
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
"laravel/tinker": "^1.0",
"yoeunes/notify": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",

84
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "94d4bf9ac7f4a933030e46a346ee2917",
"content-hash": "f4285d91336a179e52096b5a76f07d4e",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@ -2643,6 +2643,88 @@
"environment"
],
"time": "2019-03-06T09:39:45+00:00"
},
{
"name": "yoeunes/notify",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/yoeunes/notify.git",
"reference": "ec85345b990e8abc7afdf7fde74571e29e8112f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yoeunes/notify/zipball/ec85345b990e8abc7afdf7fde74571e29e8112f5",
"reference": "ec85345b990e8abc7afdf7fde74571e29e8112f5",
"shasum": ""
},
"require": {
"illuminate/session": "5.5.*|5.6.*|5.7.*|5.8.*",
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*",
"php": "^7.0|^7.1|^7.2"
},
"require-dev": {
"orchestra/testbench": "3.5.*|3.6.*|3.7.*",
"phpunit/phpunit": "^6.2|^7.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Yoeunes\\Notify\\NotifyServiceProvider"
],
"aliases": {
"Notify": "Yoeunes\\Notify\\Facades\\Notify"
}
}
},
"autoload": {
"psr-4": {
"Yoeunes\\Notify\\": "src"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes Khoubza",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes/notify",
"role": "Developer"
}
],
"description": "toastr.js, pnotify.js flush notifications for Laravel 5 and Lumen",
"homepage": "https://github.com/yoeunes/notify",
"keywords": [
"Laravel 5.6",
"alerts",
"flush",
"flush messages",
"flush notifications",
"laravel",
"laravel 5",
"laravel 5.7",
"laravel 5.8",
"laravel flush notifications",
"laravel notification",
"laravel pnotify",
"laravel toastr",
"lumen",
"messages",
"notification",
"php",
"pnotify",
"pnotify js",
"toastr",
"toastr js",
"yoeunes"
],
"time": "2019-03-08T15:50:52+00:00"
}
],
"packages-dev": [

@ -104,4 +104,8 @@ $(document).ready(function() {
});
});
}
setTimeout(function() {
$("#message").hide('blind', '', 500)
}, 3000);
});

@ -16,7 +16,13 @@
<h3 class="card-title">@yield('page-name')</h3>
<a href="{{ route('periode.create') }}" class="btn btn-outline-primary btn-sm ml-5">Tambah Periode</a>
</div>
@if(session()->has('msg'))
<div class="alert alert-{{ session()->get('type') }}" id="message" style="border-radius: 0px !important">
{{ session()->get('msg') }}
</div>
@endif
<div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap">
<thead>
<tr>
@ -29,9 +35,9 @@
</tr>
</thead>
<tbody>
@foreach ($periode as $item)
@foreach ($periode as $index => $item)
<tr>
<td><span class="text-muted">{{ $item->id }}</span></td>
<td><span class="text-muted">{{ $index+1 }}</span></td>
<td>{{ $item->nama }}</td>
<td>
{{ $item->tgl_mulai }}
@ -46,9 +52,12 @@
<a class="icon" href="javascript:void(0)" title="edit item">
<i class="fe fe-edit"></i>
</a>
<a class="icon" href="javascript:void(0)" title="delete item">
<a class="icon btn-delete" href="#!" data-id="{{ $item->id }}" title="delete item">
<i class="fe fe-trash"></i>
</a>
<form action="{{ route('periode.destroy', $item->id) }}" method="POST" id="form-{{ $item->id }}">
@csrf
</form>
</td>
</tr>
@endforeach
@ -66,3 +75,29 @@
</div>
</div>
@endsection
@section('js')
<script>
require(['jquery', 'sweetalert'], function ($, sweetalert) {
$(document).ready(function () {
$(document).on('click','.btn-delete', function(){
formid = $(this).attr('data-id');
swal({
title: 'Anda yakin ingin menghapus?',
text: 'periode yang dihapus tidak dapat dikembalikan',
dangerMode: true,
buttons: {
cancel: true,
confirm: true,
},
}).then((result) => {
if (result) {
$('#form-' + formid).submit();
}
})
})
});
});
</script>
@endsection

@ -112,6 +112,5 @@
});
});
</script>
@endsection

Loading…
Cancel
Save