Anons79 Mini Shell

Directory : /home/aplikasiposinfo/www/dispora.aplikasipos.info/app/Http/Controllers/
Upload File :
Current File : /home/aplikasiposinfo/www/dispora.aplikasipos.info/app/Http/Controllers/DataIndikatorController.php

<?php

namespace App\Http\Controllers;

use App\Models\data_indikator;
use App\Models\dataIndikator;
use App\Models\list_indikators;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;

class DataIndikatorController extends Controller
{
    public function index()
    {
        $data['data'] = dataIndikator::with('listData')->get();


        return view('dataindikator.index')->with($data);
    }
    public function store(Request $request)
    {
        $request->validate(['name' => 'required']);
        $data = ['name' => $request->name];

        dataIndikator::create($data);
        return redirect()->route('indikator.index')->with('success', 'Data successfully added');
    }
    public function update(request $request, string $id)
    {
        try {
            $decryptedId = Crypt::decryptString($id);
            $request->validate(['name' => 'required']);
            $data = ['name' => $request->name];

            dataIndikator::where('id', $decryptedId)->update($data);
            return redirect()->route('indikator.index')->with('success', 'Data successfully changed');
        } catch (DecryptException $e) {
            return redirect()->back()->with('error', 'Invalid ID');
        }
    }
    public function destroy(string $id)
    {
        try {

            $decryptedId = Crypt::decryptString($id);

            dataIndikator::where('id', $decryptedId)->delete();
            return redirect()->route('indikator.index')->with('delete', 'Data successfully deleted');
        } catch (DecryptException $e) {
            return redirect()->back()->with('error', 'Invalid ID');
        }
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]