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">
<head> <?= $this->section('content'); ?>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head> <div class="container">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<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>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="panel-body"> <div class="panel-body">
...@@ -23,7 +10,8 @@ ...@@ -23,7 +10,8 @@
<form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post"> <form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<div class="form-group"> <div class="form-group">
<label for="name">Jenis Artikel</label> <label for="name">Jenis Artikel</label>
<select class="form-control" name="id_jenis_artikel" id="id_jenis_artikel"> <select name="id_jenis_artikel" id="id_jenis_artikel" class="form-control">
<?php foreach ($data as $value) : ?> <?php foreach ($data as $value) : ?>
<option value="<?= $value['id_jenis_artikel']; ?>"> <option value="<?= $value['id_jenis_artikel']; ?>">
...@@ -33,19 +21,17 @@ ...@@ -33,19 +21,17 @@
</select> </select>
</div> </div>
<div class="custom-file"> <div class="form-group">
<input type="file" class="custom-file-input" id="gambar"> <label for="gambar">Gambar</label>
<label class="custom-file-label" for="gambar">Choose file...</label> <input type="file" class="form-control" name="gambar" id="gambar">
<input type="file" class="custom-file-input" name="gambar" id="gambar">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="judul_artikel">Judul Artikel</label> <label for="judul_artikel">Judul Artikel</label>
<input class="form-control" type="text" class="form-control" name="judul_artikel" id="judul_artikel"> <input type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="isi_artikel">Isi</label> <label for="isi_artikel">Isi</label>
<textarea class="form-control" type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea> <textarea type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div> </div>
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success">Submit</button>
</form> </form>
...@@ -53,9 +39,6 @@ ...@@ -53,9 +39,6 @@
</div> </div>
</div> </div>
</div> </div>
</body>
</html> <?= $this->endSection(); ?>
\ No newline at end of file \ 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'); ?>
<?= $this->section('content'); ?>
<div class="container">
<div class="row">
<div class="col">
<div class="panel-body">
<hr> <hr>
<form class="" action="<?= base_url('ArtikelController/editArtikel/' . $modelId['id_artikel']); ?>" method="post"> <form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/editArtikel/' . $modelId['id_artikel']); ?>" method="post">
<div class="form-group"> <div class="form-group">
<label for="name">Jenis Artikel</label> <label for="name">Jenis Artikel</label>
<select name="id_jenis_artikel" id="id_jenis_artikel" value="<?= $modelId['id_jenis_artikel'] ?>"> <select class="form-control" name="id_jenis_artikel" id="id_jenis_artikel" value="<?= $modelId['id_jenis_artikel'] ?>">
<?php foreach ($data as $value) : ?> <?php foreach ($data as $value) : ?>
<option value="<?= $value['id_jenis_artikel']; ?>"> <option value="<?= $value['id_jenis_artikel']; ?>">
...@@ -28,8 +35,13 @@ ...@@ -28,8 +35,13 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="isi_artikel">Isi</label> <label for="isi_artikel">Isi</label>
<input type="text" class="form-control" name="isi_artikel" id="isi_artikel" value="<?= $modelId['isi_artikel'] ?>"> <textarea class="form-control" type="text" class="form-control" name="isi_artikel" id="isi_artikel"><?= $modelId['isi_artikel'] ?></textarea>
</div> </div>
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success">Submit</button>
</form> </form>
</div>
</div>
</div>
</div> </div>
<?= $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