I got this error when i run edit method.
SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'order clause' (SQL: select * from
tbl_departement
order by1
desc limit 15 offset 0)
here is the method in my controller:
public function edit($id){
$page = session('departementPage');
$edit = Departement::find($id);
$departement = Departement::orderBy('id_departement','asc')->paginate($page);
return view('/akun/admin_0/departement/index')->with('edits',$edit)->with('departements',$departement)->with('sort','1')->with('page',$page);
}
public function update(Request $request, $id){
if ($request->input_id_departement != '') {
$get_id_departement = Departement::where('id_departement','=',$request->input_id_departement)->where('id_departement','!=',$id)->count();
if ($get_id_departement > 0) {
return redirect()->back()->with('message','ID Departement sudah digunakan \n silahkan masukan ID Departement lainnya!');
}else{
Departement::find($id)->update([
'id_departement' => $request->input_id_departement,
'nama_departement' => $request->input_nama_departement
] );
return redirect('/departement')->with('message','Data departement berhasil diupdate');
}
}else{
Departement::find($id)->update([
'id_departement' => $id,
'nama_departement' => $request->input_nama_departement
] );
return redirect('/departement')->with('message','Data departement berhasil diupdate');
}
}
here is the Departement.php:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Departement extends Model
{
protected $table="tbl_departement";
protected $primaryKey="id_departement";
public $incrementing=false;
public $timestamps=false;
protected $fillable=[
'id_departement','nama_departement'
];
}
here is the blade :
@extends('layouts.default')
@section('head')
<a href="/home">
<div class="menu_logo" style="background-image: url(../../../../assets/gambar/kembali.png);"></div>
</a>
@endsection
@section('content')
<script type="text/javascript">
var cek = "tampil";
function opennav(){
if (cek == "tampil") {
document.getElementById("sidebar").style.width = "20px";
document.getElementById("table_container").style.width = "auto";
document.getElementById("table_container").style.right = "20px";
document.getElementById("table_container").style.transition = "all 0.5s";
cek = "tutup";
}else{
document.getElementById("sidebar").style.width = "25%";
document.getElementById("table_container").style.width = "75%";
document.getElementById("table_container").style.right = "25%";
document.getElementById("table_container").style.transition = "all 0.5s";
cek = "tampil";
}
}
</script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<div class="table_container" style="left: 0px;" id="table_container">
<div style="margin-left: 50px; margin-top: 50px">
</div>
<form method="post" action="/departement/pilih_page" style="margin-left: 50px;margin-bottom: 20px;">
<select name="input_page" class="inputPilihPage">
<option value=""></option>
<option value="5">5</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<input type="submit" name="tampilkan" value="Tampilkan" class="btnPilihPage">
</form>
<table class="table2" align="center" onclick="tbl_click()">
<?php
if ($sort == "1") {
$sort_type = "asc";
}else{
$sort_type = "desc";
}
?>
<tr>
<?php
if (empty($page)) {
$page = 25;
}
?>
<th class="th"a></th>
<th class="th" style="text-align: center;"><a href="/departement/id_departement/">ID departement</a></th>
<th class="th" style="text-align: center;"><a href="/departement/nama_departement/">Nama departement</a></th>
</tr>
<?php
$warna = "white";
?>
@foreach ($departements as $data)
<tr>
<td align="center" style="background-color: <?php echo $warna; ?>">
<form action="/departement/" method="post">
<input type="submit" name="delete_min" style="background-image: url('../../../../assets/gambar/delete.png');" class="btn_table" value="" onclick="return confirm('Anda yakin ingin menghapus data ini?')">
<input type="hidden" name="_method" value="DELETE">
</form>
<form action="/departement//edit" method="post">
<input type="submit" name="edit_min" style="background-image: url('../../../../assets/gambar/edit.png');" class="btn_table" value="">
</form>
</td>
<td align="center" style="background-color: <?php echo $warna; ?>"></td>
<td align="center" style="background-color: <?php echo $warna; ?>"></td>
</tr>
@endforeach
</table>
</div>
<div class="sidebar" id="sidebar">
<button onclick="opennav()" class="btn_slide" id="btn_slide" style="height:100%; bottom: 0px; width: 20px;background-color: grey;float: left;border:0px;color: white; position: fixed;">
>
</button>
<?php if ($edits == '') {?>
<form method="post" action="/departement">
<table class="table_input" align="center" id="table_input">
<tr>
<td colspan="2">ID Departement</td>
</tr>
<tr>
<td colspan="2"><input type="text" name="input_id_departement" class="input_admin" value=""></td>
</tr>
<tr>
<td colspan="2">Nama Departement</td>
</tr>
<tr>
<td colspan="2"><input type="text" name="input_nama_departement" class="input_admin" required="" value=""></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="input" value="input" class="btn_admin"></td>
</tr>
</table>
</form>
<?php }else{?>
<form method="post" action="update">
<table class="table_input" align="center" id="table_input">
<tr>
<td colspan="2">ID Departement</td>
</tr>
<tr>
<td colspan="2"><input type="text" name="input_id_departement" class="input_admin" value=""></td>
</tr>
<tr>
<td colspan="2">Nama Departement</td>
</tr>
<tr>
<td colspan="2"><input type="text" name="input_nama_departement" class="input_admin" required="" value=""></td>
</tr>
<tr>
<td><input type="submit" name="update" value="update" class="btn_admin"></td>
<input type="hidden" name="_method" value="PUT">
</form>
<form action="/departement/batal">
<td><input type="submit" name="batal" value="batal" class="btn_admin"></td>
</form>
</tr>
</table>
<?php } ?>
</div>
@endsection
please help me, thank you
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3lE4kmU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire