public function deleteRow($name, $id)
{
Laralum::permissionToAccess('laralum.CRUD.access');
# Check if table exists
if (!Schema::hasTable($name)) {
abort(404);
}
# Check if column exists
if (!Schema::hasColumn($name, 'id')) {
abort(404);
}
# Check if you're allowed to delete rows
require 'Data/DevData.php';
if (array_key_exists($name, $data)) {
if (array_key_exists('delete', $data[$name])) {
if (!$data[$name]['delete']) {
abort(404);
}
}
}
$row = DB::table($name)->where('id', $id)->first();
# Check if su
if (property_exists($row, 'su')) {
if ($row->su) {
abort(403, trans('laralum.error_not_allowed'));
}
}
DB::table($name)->where('id', $id)->delete();
return redirect()->route('Laralum::CRUD_table', ['table' => $name])->with("success", trans('laralum.msg_row_deleted'));
}