update delete guru
This commit is contained in:
parent
1c92700241
commit
cd1b751138
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\gurumodel;
|
||||
use App\Models\Guru;
|
||||
use DataTables;
|
||||
|
||||
|
||||
|
@ -19,11 +20,29 @@ class MstGuruController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$guru = Guru::findOrFail($id);
|
||||
$nilai = gurumodel::where('nama', $id)->get();
|
||||
$dataView = $this->getDataInsert();
|
||||
// dd($nilai);
|
||||
return view('pages.mst_guru.edit', compact('guru', 'dataView', 'nilai'));
|
||||
}
|
||||
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Data::where('nama', $id)->delete();
|
||||
Guru::find($id)->delete();
|
||||
$guru = Guru::find($id);
|
||||
|
||||
if ($guru) {
|
||||
$guru->delete();
|
||||
// Lanjutkan dengan penghapusan lain atau tindakan yang sesuai
|
||||
return redirect()->route('guru.index')->with('success', 'Data guru berhasil dihapus.');
|
||||
} else {
|
||||
// Handle kasus di mana data tidak ditemukan
|
||||
return redirect()->route('guru.index')->with('error', 'Data guru tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Guru extends Model
|
||||
{
|
||||
protected $table = 'gurumodels';
|
||||
protected $primaryKey = 'nama';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['guru', 'nip'];
|
||||
|
||||
public function getGuruByRoleId($role_id)
|
||||
{
|
||||
return $this->where('id_role', $role_id)->get();
|
||||
}
|
||||
|
||||
public function getAllGuru()
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
public function insertGuru($data)
|
||||
{
|
||||
return $this->create($data);
|
||||
}
|
||||
|
||||
public function updateGuru($id, $data)
|
||||
{
|
||||
return $this->where('nama', $id)->update($data);
|
||||
}
|
||||
|
||||
public function deleteGuru($id)
|
||||
{
|
||||
return $this->where('nama', $id)->delete();
|
||||
}
|
||||
|
||||
public function getGurusSelect($role_id)
|
||||
{
|
||||
return $this->where('id_role', $role_id)->get();
|
||||
}
|
||||
|
||||
public function getLastGuruID()
|
||||
{
|
||||
return $this->select('nama')->orderBy('nama', 'DESC')->first();
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
|
||||
class gurumodel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
@ -12,4 +14,15 @@ class gurumodel extends Model
|
|||
'nama', 'nipa', 'email', 'kabupaten','nohp2',
|
||||
];
|
||||
|
||||
public function updateBalita($id, $data)
|
||||
{
|
||||
return $this->where('nama', $id)->update($data);
|
||||
}
|
||||
|
||||
public function deleteGuru($id)
|
||||
{
|
||||
return $this->where('nama', $id)->delete();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -215,16 +215,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<tbody>
|
||||
<?php foreach ($dataView as $item) : ?>
|
||||
<?php foreach ($dataView as $guru) : ?>
|
||||
<tr>
|
||||
<td><?php echo $item['nama'] . '(' . $item['detail'] . ')'; ?></td>
|
||||
<td><?php echo $guru['nama'] . '(' . $guru['detail'] . ')'; ?></td>
|
||||
|
||||
<?php
|
||||
$no = 1;
|
||||
foreach ($item['data'] as $dataItem) :
|
||||
foreach ($guru['data'] as $dataGuru) :
|
||||
$isChecked = false;
|
||||
if (isset($nilai)) {
|
||||
foreach ($nilai as $value) {
|
||||
if (isset($data)) {
|
||||
foreach ($data as $value) {
|
||||
?>
|
||||
<script>
|
||||
console.log(<?php echo json_encode($value); ?>);
|
||||
|
@ -240,7 +240,7 @@
|
|||
}
|
||||
?>
|
||||
<td>
|
||||
<input type="radio" name="nilai[<?php echo $dataItem->kdKriteria ?>]" value="<?php echo $dataItem->value ?>" <?php echo $isChecked ? 'checked="checked"' : '' ?> /> <?php echo $dataItem->subKriteria; ?>
|
||||
<input type="radio" name="data[<?php echo $dataItem->kdKriteria ?>]" value="<?php echo $dataItem->value ?>" <?php echo $isChecked ? 'checked="checked"' : '' ?> /> <?php echo $dataItem->subKriteria; ?>
|
||||
</td>
|
||||
<?php
|
||||
$no++;
|
||||
|
|
Loading…
Reference in New Issue