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 Illuminate\Http\Request;
|
||||||
use App\Models\gurumodel;
|
use App\Models\gurumodel;
|
||||||
|
use App\Models\Guru;
|
||||||
use DataTables;
|
use DataTables;
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,11 +20,29 @@ class MstGuruController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
Data::where('nama', $id)->delete();
|
$guru = Guru::findOrFail($id);
|
||||||
Guru::find($id)->delete();
|
$nilai = gurumodel::where('nama', $id)->get();
|
||||||
|
$dataView = $this->getDataInsert();
|
||||||
return redirect()->route('guru.index')->with('success', 'Data guru berhasil dihapus.');
|
// dd($nilai);
|
||||||
|
return view('pages.mst_guru.edit', compact('guru', 'dataView', 'nilai'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$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\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class gurumodel extends Model
|
class gurumodel extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
@ -12,4 +14,15 @@ class gurumodel extends Model
|
||||||
'nama', 'nipa', 'email', 'kabupaten','nohp2',
|
'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>
|
||||||
</div>
|
</div>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($dataView as $item) : ?>
|
<?php foreach ($dataView as $guru) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $item['nama'] . '(' . $item['detail'] . ')'; ?></td>
|
<td><?php echo $guru['nama'] . '(' . $guru['detail'] . ')'; ?></td>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$no = 1;
|
$no = 1;
|
||||||
foreach ($item['data'] as $dataItem) :
|
foreach ($guru['data'] as $dataGuru) :
|
||||||
$isChecked = false;
|
$isChecked = false;
|
||||||
if (isset($nilai)) {
|
if (isset($data)) {
|
||||||
foreach ($nilai as $value) {
|
foreach ($data as $value) {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
console.log(<?php echo json_encode($value); ?>);
|
console.log(<?php echo json_encode($value); ?>);
|
||||||
|
@ -240,7 +240,7 @@
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td>
|
<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>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
$no++;
|
$no++;
|
||||||
|
|
Loading…
Reference in New Issue