Commit c55db80c by KyrieCettyara

perbaikan fungsi admin

parent f36e6cdb
...@@ -89,6 +89,8 @@ class ArtikelController extends BaseController ...@@ -89,6 +89,8 @@ class ArtikelController extends BaseController
$imageName = $file->getRandomName(); $imageName = $file->getRandomName();
$file->move('upload/', $imageName); $file->move('upload/', $imageName);
} }
$newData = [ $newData = [
'id_jenis_artikel' => $this->request->getVar('id_jenis_artikel'), 'id_jenis_artikel' => $this->request->getVar('id_jenis_artikel'),
'gambar' => $imageName, 'gambar' => $imageName,
...@@ -121,9 +123,17 @@ class ArtikelController extends BaseController ...@@ -121,9 +123,17 @@ class ArtikelController extends BaseController
if ($this->request->getMethod() == "post") { if ($this->request->getMethod() == "post") {
$file = $this->request->getFile('gambar');
if ($file->isValid() && !$file->hasMoved()) {
$imageName = $file->getRandomName();
$file->move('upload/', $imageName);
}
$newData = [ $newData = [
'id_jenis_artikel' => $this->request->getVar('id_jenis_artikel'), 'id_jenis_artikel' => $this->request->getVar('id_jenis_artikel'),
'gambar' => $this->request->getVar('gambar'), 'gambar' => $imageName,
'judul_artikel' => $this->request->getVar('judul_artikel'), 'judul_artikel' => $this->request->getVar('judul_artikel'),
'isi_artikel' => $this->request->getVar('isi_artikel'), 'isi_artikel' => $this->request->getVar('isi_artikel'),
...@@ -133,7 +143,7 @@ class ArtikelController extends BaseController ...@@ -133,7 +143,7 @@ class ArtikelController extends BaseController
$session = session(); $session = session();
$session->setFlashdata("success", "Data updated successfully"); $session->setFlashdata("success", "Data updated successfully");
return redirect()->to(base_url('kuliner/7')); return redirect()->to(base_url('admin'));
} }
......
<!DOCTYPE html> <?= $this->extend('admin/side_menu'); ?>
<html lang="en">
<?= $this->section('content'); ?>
<head>
<meta charset="UTF-8"> <div class="container">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <div class="row">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <div class="col">
<div class="panel-body">
<head> <hr>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <div class="form-group">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <label for="name">Jenis Artikel</label>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <select name="id_jenis_artikel" id="id_jenis_artikel" class="form-control">
</head> <?php foreach ($data as $value) : ?>
<body> <option value="<?= $value['id_jenis_artikel']; ?>">
<div class="container"> <?= $value['nama_jenis_artikel']; ?>
<div class="row"> </option>
<div class="col"> <?php endforeach; ?>
<div class="panel-body"> </select>
<hr>
<form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post"> </div>
<div class="form-group"> <div class="form-group">
<label for="name">Jenis Artikel</label> <label for="gambar">Gambar</label>
<select class="form-control" name="id_jenis_artikel" id="id_jenis_artikel"> <input type="file" class="form-control" name="gambar" id="gambar">
<?php foreach ($data as $value) : ?> </div>
<div class="form-group">
<option value="<?= $value['id_jenis_artikel']; ?>"> <label for="judul_artikel">Judul Artikel</label>
<?= $value['nama_jenis_artikel']; ?> <input type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</option> </div>
<?php endforeach; ?> <div class="form-group">
</select> <label for="isi_artikel">Isi</label>
<textarea type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div> </div>
<div class="custom-file"> <button type="submit" class="btn btn-success">Submit</button>
<input type="file" class="custom-file-input" id="gambar"> </form>
<label class="custom-file-label" for="gambar">Choose file...</label>
<input type="file" class="custom-file-input" name="gambar" id="gambar">
</div>
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label>
<input class="form-control" type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div>
<div class="form-group">
<label for="isi_artikel">Isi</label>
<textarea class="form-control" type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?= $this->endSection(); ?>
</body> \ No newline at end of file
</html>
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div class="card"> <div class="card">
<?php $image = $value['gambar']; ?> <?php $image = $value['gambar']; ?>
<img id="gambar" src="<?php echo base_url("upload/$image"); ?> " alt="image" /> <img id="gambar" src="<?php echo base_url("upload/$image"); ?> " />
<div class=" card-body"> <div class=" card-body">
......
<div class="panel-body"> <?= $this->extend('admin/side_menu'); ?>
<hr>
<form class="" action="<?= base_url('ArtikelController/editArtikel/' . $modelId['id_artikel']); ?>" method="post">
<div class="form-group">
<label for="name">Jenis Artikel</label>
<select name="id_jenis_artikel" id="id_jenis_artikel" value="<?= $modelId['id_jenis_artikel'] ?>">
<?php foreach ($data as $value) : ?>
<option value="<?= $value['id_jenis_artikel']; ?>"> <?= $this->section('content'); ?>
<?= $value['nama_jenis_artikel']; ?>
</option>
<?php endforeach; ?>
</select>
</div> <div class="container">
<div class="form-group"> <div class="row">
<label for="gambar">Gambar</label> <div class="col">
<input type="file" class="form-control" name="gambar" id="gambar" value="<?= $modelId['gambar'] ?>"> <div class="panel-body">
</div> <hr>
<div class="form-group"> <form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/editArtikel/' . $modelId['id_artikel']); ?>" method="post">
<label for="judul_artikel">Id Artikel</label> <div class="form-group">
<input type="text" class="form-control" name="judul_artikel" id="id_artikel" value="<?= $modelId['id_artikel'] ?>" readonly> <label for="name">Jenis Artikel</label>
</div> <select class="form-control" name="id_jenis_artikel" id="id_jenis_artikel" value="<?= $modelId['id_jenis_artikel'] ?>">
<div class="form-group"> <?php foreach ($data as $value) : ?>
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label> <option value="<?= $value['id_jenis_artikel']; ?>">
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel " value="<?= $modelId['judul_artikel'] ?>"> <?= $value['nama_jenis_artikel']; ?>
</div> </option>
<div class="form-group"> <?php endforeach; ?>
<label for="isi_artikel">Isi</label> </select>
<input type="text" class="form-control" name="isi_artikel" id="isi_artikel" value="<?= $modelId['isi_artikel'] ?>">
</div>
<div class="form-group">
<label for="gambar">Gambar</label>
<input type="file" class="form-control" name="gambar" id="gambar" value="<?= $modelId['gambar'] ?>">
</div>
<div class="form-group">
<label for="judul_artikel">Id Artikel</label>
<input type="text" class="form-control" name="judul_artikel" id="id_artikel" value="<?= $modelId['id_artikel'] ?>" readonly>
</div>
<div class="form-group">
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label>
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel " value="<?= $modelId['judul_artikel'] ?>">
</div>
<div class="form-group">
<label for="isi_artikel">Isi</label>
<textarea class="form-control" type="text" class="form-control" name="isi_artikel" id="isi_artikel"><?= $modelId['isi_artikel'] ?></textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div> </div>
<button type="submit" class="btn btn-success">Submit</button> </div>
</form> </div>
</div> </div>
\ No newline at end of file
<?= $this->endSection(); ?>
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<?= $this->section('content'); ?> <?= $this->section('content'); ?>
<a href=" <?= base_url('add-artikel'); ?>" class="btn btn-primary">Tambah Artikel</a>
<?php foreach ($data as $value) : ?> <?php foreach ($data as $value) : ?>
<?php <?php
$isi_artikel = $value['isi_artikel']; $isi_artikel = $value['isi_artikel'];
......
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