update
parent
35dc949f9e
commit
f055b22ba8
|
|
@ -73,16 +73,17 @@ class DataAktivitasController implements HasMiddleware
|
|||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = $this->fileService->find($id);
|
||||
if ($data) {
|
||||
$data['storagePath'] = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year;
|
||||
$datas['data'] = $this->fileService->find($id);
|
||||
// dd($datas['data']);
|
||||
if ($datas['data']->file_upload) {
|
||||
$datas['storagePath'] = 'data_aktivitas/' . $datas['data']->sector . '/' . $datas['data']->inventory_year;
|
||||
}
|
||||
|
||||
$data['sectors'] = $this->fileService->getSectors();
|
||||
$data['route'] = $this->route;
|
||||
$data['title'] = $this->title;
|
||||
$datas['sectors'] = $this->fileService->getSectors();
|
||||
$datas['route'] = $this->route;
|
||||
$datas['title'] = $this->title;
|
||||
|
||||
return view($this->template.'.edit', $data);
|
||||
return view($this->template.'.edit', $datas);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
|
|
@ -117,7 +118,7 @@ class DataAktivitasController implements HasMiddleware
|
|||
$storagePath = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year;
|
||||
}
|
||||
|
||||
$this->fileService->destroy($cms, $storagePath);
|
||||
$this->fileService->destroy($data, $storagePath);
|
||||
|
||||
return redirect()->route($this->route.'.index')->with('success', 'File Data Aktivitas berhasil dihapus.');
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -138,20 +139,23 @@ class DataAktivitasController implements HasMiddleware
|
|||
|
||||
public function grid(Request $request)
|
||||
{
|
||||
|
||||
// dd($request->all());
|
||||
$_data = [];
|
||||
$user = Auth::user();
|
||||
$scope = $user->getScope();
|
||||
$data = CmsFileDataAktivitas::rowActive();
|
||||
|
||||
// dd($data->get());
|
||||
if ($scope === LingkupAksesData::INTERNAL->value) {
|
||||
dd('a');
|
||||
$data->whereHas('creator', function ($q) use ($user) {
|
||||
$q->where('agency_id', $user->agency_id);
|
||||
});
|
||||
} else if ($scope === '') {
|
||||
$data->where('created_by', null);
|
||||
// $data->where('created_by', null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Apply category filter if a category is selected
|
||||
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
||||
$data = $data->where('sector', $request->sectorFilter);
|
||||
|
|
@ -181,9 +185,9 @@ class DataAktivitasController implements HasMiddleware
|
|||
}
|
||||
|
||||
if ($row->file_upload) {
|
||||
$storagePath = 'data_aktivitas/' . $row->sector . '/' . $row->inventory_year;
|
||||
$file = '<a href="' . Storage::url($storagePath . '/' . $row->file_upload) . '" class="btn btn-info">
|
||||
<i class="ti ti-download"></i>
|
||||
$storagePath = 'storage/data_aktivitas/' . $row->sector . '/' . $row->inventory_year;
|
||||
$file = '<a href="' . asset($storagePath . '/' . $row->file_upload) . '" class="btn btn-sm w-100 btn-info">
|
||||
<i class="bx bx-download"></i>
|
||||
</a>';
|
||||
} else {
|
||||
$file = '<span class="badge badge-secondary">No File</span>';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ use Yajra\DataTables\DataTables;
|
|||
|
||||
class PeraturanController implements HasMiddleware
|
||||
{
|
||||
protected $title = 'Data Pengumuman';
|
||||
protected $template = 'modules.setting.file-peraturan';
|
||||
protected $route = 'modules.pengaturan.pengumuman';
|
||||
protected $fileService;
|
||||
|
||||
public function __construct(PeraturanService $fileService)
|
||||
|
|
@ -29,42 +32,18 @@ class PeraturanController implements HasMiddleware
|
|||
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$query = $this->fileService->getAll();
|
||||
$datas['route'] = $this->route;
|
||||
$datas['title'] = $this->title;
|
||||
|
||||
$result = datatables()->of($query)
|
||||
->addColumn('file_upload', function ($row) {
|
||||
if ($row->file_upload) {
|
||||
$storagePath = 'peraturan';
|
||||
return '<a href="' . Storage::url($storagePath . '/' . $row->file_upload) . '" class="btn btn-info">
|
||||
<i class="ti ti-download"></i>
|
||||
</a>';
|
||||
} else {
|
||||
return '<span class="badge badge-secondary">No File</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('action', function ($data) {
|
||||
$actionBtn = '<a href="' . route('peraturan.edit', $data->id) . '" class="btn btn-primary">Edit</a>';
|
||||
$actionBtn .= ' <form method="POST" action="' . route('peraturan.destroy', $data->id) . '" style="display: inline">';
|
||||
$actionBtn .= csrf_field();
|
||||
$actionBtn .= method_field('DELETE');
|
||||
$actionBtn .= '<button type="submit" class="btn btn-danger" onclick="return confirm(\'Are you sure?\')">Delete</button>';
|
||||
$actionBtn .= '</form>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['file_upload', 'action'])
|
||||
->make(true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return view('setting.file-peraturan.index');
|
||||
return view($this->template.'.index',$datas);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('setting.file-peraturan.create');
|
||||
$datas['route'] = $this->route;
|
||||
$datas['title'] = $this->title;
|
||||
return view($this->template.'.create',$datas);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
|
|
@ -79,7 +58,7 @@ class PeraturanController implements HasMiddleware
|
|||
try {
|
||||
$this->fileService->save($request->all());
|
||||
|
||||
return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.');
|
||||
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.');
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||
}
|
||||
|
|
@ -87,12 +66,13 @@ class PeraturanController implements HasMiddleware
|
|||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = $this->fileService->find($id);
|
||||
if ($data) {
|
||||
$data['storagePath'] = 'peraturan';
|
||||
$datas['data'] = $this->fileService->find($id);
|
||||
if ($datas['data']) {
|
||||
$datas['storagePath'] = 'peraturan';
|
||||
}
|
||||
|
||||
return view('setting.file-peraturan.edit', compact('data'));
|
||||
$datas['route'] = $this->route;
|
||||
$datas['title'] = $this->title;
|
||||
return view($this->template.'.edit', $datas);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
|
|
@ -110,7 +90,7 @@ class PeraturanController implements HasMiddleware
|
|||
|
||||
$this->fileService->save($data);
|
||||
|
||||
return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.');
|
||||
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.');
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal diperbarui. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||
}
|
||||
|
|
@ -124,11 +104,49 @@ class PeraturanController implements HasMiddleware
|
|||
$storagePath = 'peraturan';
|
||||
}
|
||||
|
||||
$this->fileService->destroy($cms, $storagePath);
|
||||
$this->fileService->destroy($data, $storagePath);
|
||||
|
||||
return redirect()->route('unit.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.');
|
||||
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.');
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal dihapus. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function grid(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$_data = [];
|
||||
$data = $this->fileService->getAll();
|
||||
|
||||
foreach ($data as $key => $row) {
|
||||
|
||||
$btn = '<a href="' . route($this->route.'.edit', $row->id) . '" class="btn btn-sm btn-primary">Edit</a>';
|
||||
$btn .= ' <form method="POST" action="' . route($this->route.'.destroy', $row->id) . '" style="display: inline">';
|
||||
$btn .= csrf_field();
|
||||
$btn .= method_field('DELETE');
|
||||
$btn .= '<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm(\'Are you sure?\')">Delete</button>';
|
||||
$btn .= '</form>';
|
||||
|
||||
if ($row->file_upload) {
|
||||
$storagePath = 'storage/peraturan';
|
||||
$file = '<a href="' . asset($storagePath . '/' . $row->file_upload) . '" class="btn btn-sm w-100 btn-info">
|
||||
<i class="bx bx-download"></i>
|
||||
</a>';
|
||||
} else {
|
||||
$file = '<span class="badge badge-secondary">No File</span>';
|
||||
}
|
||||
|
||||
|
||||
$_data[] = [
|
||||
'no' => $key+1,
|
||||
'file' => $file,
|
||||
'name' => $row->name,
|
||||
'description' => $row->description,
|
||||
'action' => @$btn,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return response()->json($_data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
/Applications/MAMP/htdocs/sigd_new/storage/app/public
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
id="file_document" name="file_document">
|
||||
@if ($data->file_upload)
|
||||
<div class="input-group-append">
|
||||
<a href="{{ Storage::url($data->storagePath . '/' . $data->file_upload) }}"
|
||||
<a href="{{ asset('storage/'.$storagePath . '/' . $data->file_upload) }}"
|
||||
class="btn btn-success" download>Download File</a>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@
|
|||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2 pr-1" id="inventoryYearContainer">
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
@extends('layouts.master')
|
||||
|
||||
@section('title', 'Upload Pengumuman / File Peraturan-Peraturan')
|
||||
|
||||
@section('content')
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 font-weight-bold">Upload Pengumuman / File Peraturan-Peraturan</h5>
|
||||
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
|
@ -15,7 +13,7 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('peraturan.store') }}" enctype="multipart/form-data">
|
||||
<form method="POST" action="{{ route($route.'.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="form-group">
|
||||
|
|
@ -54,7 +52,7 @@
|
|||
{{-- Jenis file yang dibolehkan: pdf, PDF, jpg, JPG, jpeg, JPEG, png, PNG --}}
|
||||
</div>
|
||||
|
||||
<a href="{{ route('peraturan.index') }}" class="btn btn-secondary">Kembali</a>
|
||||
<a href="{{ route($route.'.index') }}" class="btn btn-secondary">Kembali</a>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,14 @@
|
|||
@extends('layouts.master')
|
||||
|
||||
@section('title', 'Edit Pengumuman / File Peraturan-Peraturan')
|
||||
|
||||
@section('content')
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 font-weight-bold">Edit Pengumuman / File Peraturan-Peraturan</h5>
|
||||
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if ($errors->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ $errors->first('error') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('peraturan.update', $data->id) }}" enctype="multipart/form-data">
|
||||
<form method="POST" action="{{ route($route.'.update', $data->id) }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
|
|
@ -47,7 +40,7 @@
|
|||
id="file_document" name="file_document">
|
||||
@if ($data->file_upload)
|
||||
<div class="input-group-append">
|
||||
<a href="{{ Storage::url($data->storagePath . '/' . $data->file_upload) }}"
|
||||
<a href="{{ asset('storage/'.$storagePath . '/' . $data->file_upload) }}"
|
||||
class="btn btn-success" download>Download File</a>
|
||||
</div>
|
||||
@endif
|
||||
|
|
@ -61,7 +54,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
<a href="{{ route('peraturan.index') }}" class="btn btn-secondary">Kembali</a>
|
||||
<a href="{{ route($route.'.index') }}" class="btn btn-secondary">Kembali</a>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,34 +1,38 @@
|
|||
@extends('layouts.master')
|
||||
|
||||
@section('title', 'List Pengumuman / File Peraturan-Peraturan')
|
||||
|
||||
@section('content')
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 font-weight-bold">List Pengumuman / File Peraturan-Peraturan</h5>
|
||||
<a href="{{ route('peraturan.create') }}" class="btn btn-primary float-right">Upload</a>
|
||||
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Upload</a>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table align-items-center mb-0 display" id="data-table" style="width:100%">
|
||||
<thead>
|
||||
<table class="table w-100"
|
||||
data-search="true"
|
||||
data-toggle="table"
|
||||
data-pagination="true"
|
||||
data-toolbar="#toolbar"
|
||||
data-show-refresh="false"
|
||||
data-url="{{route($route.'.grid')}}"
|
||||
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
||||
data-sort-name="ids"
|
||||
data-sort-order="desc"
|
||||
data-page-size="10"
|
||||
data-id-field="id"
|
||||
id="grid-data">
|
||||
<thead class="table-primary text-primary">
|
||||
<tr>
|
||||
<th scope="col">Judul</th>
|
||||
<th scope="col" width="5%">File</th>
|
||||
<th scope="col">Keterangan</th>
|
||||
<th scope="col" width="15%">Aksi</th>
|
||||
<th data-width="150" data-field="action">#</th>
|
||||
<th data-field="name">Judul</th>
|
||||
<th data-field="file">File</th>
|
||||
<th data-field="description">Keterangan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -36,37 +40,4 @@
|
|||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#data-table').DataTable({
|
||||
pageLength: 10,
|
||||
responsive: true,
|
||||
serverSide: true,
|
||||
scrollX: true,
|
||||
searchDelay: 1000,
|
||||
ajax: {
|
||||
url: '{{ route('peraturan.index') }}',
|
||||
},
|
||||
columns: [{
|
||||
data: 'name',
|
||||
name: 'name'
|
||||
},
|
||||
{
|
||||
data: 'file_upload',
|
||||
name: 'file_upload',
|
||||
},
|
||||
{
|
||||
data: 'description',
|
||||
name: 'description'
|
||||
},
|
||||
{
|
||||
data: 'action',
|
||||
name: 'action',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Reference in New Issue