131 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			131 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Controllers\Modules\Konten;
 | 
						|
 | 
						|
use App\Http\Controllers\Controller;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use App\Models\Konten\Galeri;
 | 
						|
use App\Models\Konten\ImageGaleri;
 | 
						|
 | 
						|
class GaleriController extends Controller
 | 
						|
{
 | 
						|
    private $template = 'modules.konten.galeri';
 | 
						|
    private $route = 'modules.konten.galeri';
 | 
						|
    private $title = 'Konten Galeri';
 | 
						|
 | 
						|
    /**
 | 
						|
     * Display a listing of the resource.
 | 
						|
     */
 | 
						|
    public function index()
 | 
						|
    {
 | 
						|
        $data['breadcrumbs'] = [
 | 
						|
            ['name' => 'Dashboard','url' => url('dashboard')],
 | 
						|
            ['name' => 'Konten'],
 | 
						|
            ['name' => 'Galeri','active' => true],
 | 
						|
        ];
 | 
						|
 | 
						|
        $data['route'] = $this->route;
 | 
						|
        $data['title'] = $this->title;
 | 
						|
 | 
						|
        return view($this->template.'.index',$data);
 | 
						|
    }
 | 
						|
 | 
						|
    public function grid(Request $request)
 | 
						|
    {
 | 
						|
        $data = Galeri::all();
 | 
						|
        
 | 
						|
        
 | 
						|
        foreach ($data as $key => $row) {
 | 
						|
 | 
						|
            $action = '';
 | 
						|
 | 
						|
            if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
 | 
						|
                $action .= '<a href="'.url('konten/galeri/update/'.encode_id($row->GaleriId)).'" data-toggle="tooltip" title="Edit Data" class="btn btn-xs btn-block btn-primary"><i class="fal fa-pencil text-white"></i></a>';
 | 
						|
                $action .= '<a href="#" data-href="'.url('konten/galeri/delete/'.encode_id($row->GaleriId)).'" data-toggle="tooltip" title="Hapus Data" class="remove_data btn btn-xs btn-block btn-danger"><i class="fal fa-trash text-white"></i></a>';
 | 
						|
            }
 | 
						|
 | 
						|
            $_data[] = [
 | 
						|
                'no'                => $key+1,
 | 
						|
                'id'                => encode_id($row->GaleriId),
 | 
						|
                'judul'             => $row->judul,
 | 
						|
                'action'            => $action,
 | 
						|
            ];
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        return response()->json($_data);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Show the form for creating a new resource.
 | 
						|
     */
 | 
						|
    public function create()
 | 
						|
    {
 | 
						|
        $data['breadcrumbs'] = [
 | 
						|
            ['name' => 'Dashboard','url' => url('dashboard')],
 | 
						|
            ['name' => 'Konten'],
 | 
						|
            ['name' => 'Galeri','url' => url('konten/galeri')],
 | 
						|
            ['name' => 'Tambah Galeri','active' => true],
 | 
						|
        ];
 | 
						|
 | 
						|
        $data['route'] = $this->route;
 | 
						|
        $data['title'] = $this->title;
 | 
						|
 | 
						|
        return view($this->template.'.form',$data);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Store a newly created resource in storage.
 | 
						|
     */
 | 
						|
    public function store(Request $request)
 | 
						|
    {
 | 
						|
        //
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Display the specified resource.
 | 
						|
     */
 | 
						|
    public function show(string $id)
 | 
						|
    {
 | 
						|
        //
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Show the form for editing the specified resource.
 | 
						|
     */
 | 
						|
    public function edit(string $id)
 | 
						|
    {
 | 
						|
        $data['breadcrumbs'] = [
 | 
						|
            ['name' => 'Dashboard','url' => url('dashboard')],
 | 
						|
            ['name' => 'Konten'],
 | 
						|
            ['name' => 'Galeri','url' => url('konten/galeri')],
 | 
						|
            ['name' => 'Edit Galeri','active' => true],
 | 
						|
        ];
 | 
						|
 | 
						|
        $data['route'] = $this->route;
 | 
						|
        $data['title'] = $this->title;
 | 
						|
        $data['item'] = Galeri::find(decode_id($id));
 | 
						|
 | 
						|
        return view($this->template.'.form',$data);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Update the specified resource in storage.
 | 
						|
     */
 | 
						|
    public function update(Request $request, string $id)
 | 
						|
    {
 | 
						|
        
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Remove the specified resource from storage.
 | 
						|
     */
 | 
						|
    public function delete($id)
 | 
						|
    {
 | 
						|
        $keyId = decode_id($id);
 | 
						|
        $form = Galeri::where('GaleriId',$keyId)->delete();
 | 
						|
 | 
						|
        return response()->json(['success' => true,'message' => 'Berhasil update data','type' => 'success']);
 | 
						|
    }
 | 
						|
}
 |