Commit 087b1a4e by Siti Aisah

fix konferensi

parent db69eb08
...@@ -139,7 +139,7 @@ public function store_kegiatan(Request $request) { ...@@ -139,7 +139,7 @@ public function store_kegiatan(Request $request) {
try{ try{
$data = [ $data = [
'nama' => $request->nama, 'nama' => strip_tags($request->nama),
'harga' => $request->harga 'harga' => $request->harga
]; ];
Kegiatan::query()->create($data); Kegiatan::query()->create($data);
...@@ -217,7 +217,8 @@ public function index_konferensi() { ...@@ -217,7 +217,8 @@ public function index_konferensi() {
public function store_konferensi(Request $request) { public function store_konferensi(Request $request) {
$rules = [ $rules = [
'nama' => 'required|string' 'nama' => 'required|string',
'harga' => 'required|numeric'
]; ];
$request->validate($rules, ValidationRule::getErrorMessage($rules)); $request->validate($rules, ValidationRule::getErrorMessage($rules));
...@@ -226,7 +227,8 @@ public function store_konferensi(Request $request) { ...@@ -226,7 +227,8 @@ public function store_konferensi(Request $request) {
try{ try{
$data = [ $data = [
'nama' => strip_tags($request->nama) 'nama' => strip_tags($request->nama),
'harga' => $request->harga
]; ];
Konferensi::query()->create($data); Konferensi::query()->create($data);
DB::commit(); DB::commit();
...@@ -245,7 +247,8 @@ public function store_konferensi(Request $request) { ...@@ -245,7 +247,8 @@ public function store_konferensi(Request $request) {
public function update_konferensi($id, Request $request) { public function update_konferensi($id, Request $request) {
$rules = [ $rules = [
'nama' => 'required|string' 'nama' => 'required|string',
'harga' => 'required|numeric'
]; ];
$request->validate($rules, ValidationRule::getErrorMessage($rules)); $request->validate($rules, ValidationRule::getErrorMessage($rules));
...@@ -254,7 +257,8 @@ public function update_konferensi($id, Request $request) { ...@@ -254,7 +257,8 @@ public function update_konferensi($id, Request $request) {
try{ try{
$data = [ $data = [
'nama' => $request->nama 'nama' => $request->nama,
'harga' => $request->harga
]; ];
Konferensi::query()->where('id', $id)->update($data); Konferensi::query()->where('id', $id)->update($data);
......
...@@ -17,7 +17,8 @@ class Konferensi extends Model ...@@ -17,7 +17,8 @@ class Konferensi extends Model
protected $fillable = [ protected $fillable = [
'id', 'id',
'nama' 'nama',
'harga'
]; ];
public function rKonferensi() { public function rKonferensi() {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<tr style="text-align: center;"> <tr style="text-align: center;">
<th>No.</th> <th>No.</th>
<th>Konferensi</th> <th>Konferensi</th>
<th>Harga</th>
<th>Aksi</th> <th>Aksi</th>
</tr> </tr>
</thead> </thead>
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
<tr style="text-align: center;"> <tr style="text-align: center;">
<td>{{ $no }}</td> <td>{{ $no }}</td>
<td>{{ $tr->nama}}</td> <td>{{ $tr->nama}}</td>
<td>{{ $tr->harga }}</td>
<td> <td>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#update-modal{{$tr->id}}">Ubah</button> <button type="button" class="btn btn-info" data-toggle="modal" data-target="#update-modal{{$tr->id}}">Ubah</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete-modal{{$tr->id}}">Hapus</button> <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete-modal{{$tr->id}}">Hapus</button>
...@@ -51,14 +53,21 @@ ...@@ -51,14 +53,21 @@
<form method="POST" action="{{ route('admin.create_konferensi', ['id' => $tr->id ]) }}" enctype="multipart/form-data"> <form method="POST" action="{{ route('admin.create_konferensi', ['id' => $tr->id ]) }}" enctype="multipart/form-data">
@csrf @csrf
<div class="modal-body" @if ($errors->has('nama')) has-error @endif> <div class="modal-body">
<div class="form-group" style="text-align: left"> <div class="form-group" style="text-align: left">
<label for="nama">Nama Konferensi</label> <label for="nama">Nama Konferensi</label>
<input type="text" class="form-control" id="nama" name="nama" required> <input type="text" class="form-control" id="nama" name="nama" required @if($errors->has('nama')) has-error @endif>
@if ($errors->has('nama')) @if ($errors->has('nama'))
<label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label> <label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label>
@endif @endif
</div> </div>
<div class="form-group" style="text-align: left">
<label for="harga">Harga</label>
<input type="number" class="form-control" id="harga" name="harga" required @if($errors->has('harga')) has-error @endif>
@if($errors->has('harga'))
<label id="login-error" class="error" for="harga" style="color: red">{{$errors->first('harga')}}</label>
@endif
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary ml-1">Simpan</button> <button type="submit" class="btn btn-primary ml-1">Simpan</button>
...@@ -81,14 +90,21 @@ ...@@ -81,14 +90,21 @@
<form method="POST" action="{{ route('admin.update_konferensi', ['id' => $tr->id ]) }}" enctype="multipart/form-data"> <form method="POST" action="{{ route('admin.update_konferensi', ['id' => $tr->id ]) }}" enctype="multipart/form-data">
@csrf @csrf
@method('put') @method('put')
<div class="modal-body" @if ($errors->has('nama')) has-error @endif> <div class="modal-body">
<div class="form-group" style="text-align: left"> <div class="form-group" style="text-align: left">
<label for="nama">Nama Konferensi</label> <label for="nama">Nama Konferensi</label>
<input type="text" class="form-control" id="nama" name="nama" value="{{ $tr->nama }}" required> <input type="text" class="form-control" id="nama" name="nama" value="{{ $tr->nama }}" required @if($errors->has('nama')) has-error @endif>
@if ($errors->has('nama')) @if ($errors->has('nama'))
<label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label> <label id="login-error" class="error" for="nama" style="color: red">{{$errors->first('nama')}}</label>
@endif @endif
</div> </div>
<div class="form-group" style="text-align: left">
<label for="harga">Harga</label>
<input type="text" class="form-control" id="harga" name="harga" value="{{ $tr->harga }}" required @if($errors->has('harga')) has-error @endif>
@if($errors->has('harga'))
<label id="login-error" class="error" for="harga" style="color: red">{{$errors->first('harga')}}</label>
@endif
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary ml-1">Simpan</button> <button type="submit" class="btn btn-primary ml-1">Simpan</button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment