Commit eb1400a6 by Farendi Giotivano R.P

master bidang penelitian

parent a4badc42
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
use Alert;
use Crypt;
use App\Http\Controllers\Controller;
use App\Repositories\Admin\MsBidangPenelitianKategoriRepository;
use App\Repositories\Admin\MsBidangPenelitianRepository;
use Illuminate\Http\Request;
......@@ -12,42 +13,52 @@ class BidangPenelitianController extends Controller
{
private $bidangpenelitianRepo;
public function __construct(MsBidangPenelitianRepository $bidangpenelitianRepo)
{
public function __construct(
MsBidangPenelitianKategoriRepository $bidangpenelitiankategoriRepo,
MsBidangPenelitianRepository $bidangpenelitianRepo
){
$this->bidangpenelitianRepo = $bidangpenelitianRepo;
$this->bidangpenelitiankategoriRepo = $bidangpenelitiankategoriRepo;
}
public function index()
{
//
$menu = 'bidangpenelitian';
$bidangpenelitian = $this->bidangpenelitianRepo->get();
$bidangpenelitian = $this->bidangpenelitianRepo->get(['rKategori']);
$bidangpenelitiankategori = $this->bidangpenelitiankategoriRepo->get();
//dd($bidangpenelitiankategori);
$data = [
'bidangpenelitian' => $bidangpenelitian,
'bidangpenelitiankategori' => $bidangpenelitiankategori,
'menu' => $menu
];
return view('admin.bidang.index', $data);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function bidangkategori()
{
//
$menu = 'bidangpenelitian';
$bidangpenelitiankategori = $this->bidangpenelitiankategoriRepo->get();
//dd($bidangpenelitiankategori);
$data = [
'bidangpenelitiankategori' => $bidangpenelitiankategori,
'menu' => $menu
];
return view('admin.bidang.kategori', $data);
}
public function create()
{
//
return view('admin.bidangpenelitian.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
......@@ -61,26 +72,32 @@ class BidangPenelitianController extends Controller
Alert::success('Berhasil', 'bidangpenelitian berhasil disimpan');
return redirect()->route('bidang.index', $data);
return redirect()->route('admin.bidangpenelitian.index', $data);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function kategoristore(Request $request)
{
//
$data = $request->except('_token');
$data['user_id'] = auth()->user()->id;
$bidangpenelitiankategori = $this->bidangpenelitiankategoriRepo->store($data);
$data = [
'bidangpenelitiankategori' => $bidangpenelitiankategori->id,
];
Alert::success('Berhasil', 'Kategori Bidang Penelitian berhasil disimpan');
return redirect()->route('admin.bidang.kategori', $data);
}
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
......@@ -96,13 +113,22 @@ class BidangPenelitianController extends Controller
return view('admin.bidang.edit', $data);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function kategoriedit($id)
{
//
$menu = 'bidangpenelitian';
$bidangpenelitian = $this->bidangpenelitianRepo->findId(null, $id);
$data = [
'menu' => $menu,
'bidangpenelitian' => $bidangpenelitian,
];
return view('admin.bidang.edit', $data);
}
public function update(Request $request, $id)
{
//
......@@ -120,12 +146,24 @@ class BidangPenelitianController extends Controller
return redirect()->route('bidang.index', $data);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function kategoriupdate(Request $request, $id)
{
//
$data = $request->except('_token');
$data['userid_updated'] = auth()->user()->id;
$bidangpenelitiankategori = $this->bidangpenelitiankategoriRepo->findId(null, $id);
$this->bidangpenelitiankategoriRepo->update($data, $bidangpenelitiankategori);
$data = [
'bidangpenelitiankategori' => $bidangpenelitiankategori->id,
];
Alert::success('Berhasil', 'bidangpenelitiankategori berhasil diupdated');
return redirect()->route('bidang.index', $data);
}
public function destroy($id)
{
//
......
......@@ -21,6 +21,6 @@ class MsBidangPenelitian extends Model
public function rKategori()
{
return $this->belongsTo(MsBidangPenelitian::class, 'id', 'id_kategori');
return $this->belongsTo(MsBidangPenelitianKategori::class, 'id_kategori', 'id');
}
}
<?php
namespace App\Repositories\Admin;
use App\Models\Admin\MsBidangPenelitianKategori;
use App\Repositories\Repository;
class MsBidangPenelitianKategoriRepository extends Repository
{
protected $model;
public function __construct(MsBidangPenelitianKategori $model)
{
$this->model = $model;
}
public function get($with = null, $search = null, $id = null)
{
return $this->model->when($with, function ($query) use ($with) {
return $query->with($with);
})
->when($search, function ($query) use ($search) {
return $query->where('search', $search);
})
->when($id, function ($query) use ($id) {
return $query->where('id', $id);
})
->get();
}
}
......@@ -18,29 +18,27 @@
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-6">
<div class="table-responsive mb-4 mt-4">
<a href="{{ url('admin/bidangpenelitian/create') }}" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</a>
<button type="button" data-target="#tambah" data-toggle="modal" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</button>
<table id="zero-config" class="table table-hover" style="width:100%">
<thead>
<tr>
<th>No</th>
<th>Nama Unit</th>
<th>No SK</th>
<th>Status</th>
<th style="width: 20%">Aksi</th>
<th>Kategori</th>
<th>Bidang Penelitian</th>
<th style="width: 15%">Aksi</th>
</tr>
</thead>
<tbody>
@php $no = 1; @endphp
@foreach ($fasilitas as $value)
@foreach ($bidangpenelitian as $value)
<tr>
<td>{{ $no++ }}</td>
<td>{{ $value->namaunit }}</td>
<td>{{ $value->nosk }}</td>
<td>{{ $value->status }}</td>
<td>{{ $value->rKategori->namabidang }}</td>
<td>{{ $value->nama }}</td>
<td>
<a href="{{ url('fasilitas/'.$value->id.'/edit') }}" class="btn btn-warning mb-2"><i data-feather="edit"></i> Edit</a> |
<button class="btn btn-danger mb-2 delete" data-id="{{ $value->id }}" data-file="{{$value->id}}"><i data-feather="trash-2"></i> Delete</button>
{{ Form::open(['url'=>route('fasilitas.destroy', [Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
{{-- <a href="{{ url('bidangpenelitian/'.$value->id.'/edit') }}" class="btn btn-warning mb-2"><i data-feather="edit"></i></a> | --}}
<button class="btn btn-danger mb-2 delete" data-id="{{ $value->id }}" data-file="{{$value->id}}"><i data-feather="trash-2"></i></button>
{{ Form::open(['url'=>route('admin.bidangpenelitian.destroy', [Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
{{ csrf_field() }}
{{ Form::close() }}
</td>
......@@ -54,6 +52,39 @@
</div>
<div class="modal fade" id="tambah" tabindex="-1" role="dialog" aria-labelledby="ModalTambah" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTambah">Tambah Bidang Penelitian</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
{{ Form::open(['url' => route('admin.bidangpenelitian.store'), 'method' => 'post', 'class' => 'section general-info', 'id' => 'bidangpenelitian']) }}
<div class="modal-body">
<div class="form-group">
<label>Kategori</label>
<select class="form-control mb-2" id="id_kategori" name="id_kategori">
@foreach($bidangpenelitiankategori as $item)
<option value="{{$item->id}}">{{$item->namabidang}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label>Nama Bidang Penelitian</label>
<input type="text" class="form-control mb-2" id="nama" name="nama" placeholder="Nama Bidang Penelitian">
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal"><i class="flaticon-cancel-12"></i> Batal</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
{{ Form::close() }}
</div>
</div>
</div>
@endsection
@section('js')
......
@extends('layouts.master')
@section('title')
Bidang Penelitian
@endsection
@section('header')
<div class="page-title">
<h3>Bidang Penelitian</h3>
</div>
@endsection
@section('contents')
@php
$menu = 'dashboard';
@endphp
<div class="row layout-top-spacing" id="cancel-row">
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-6">
<div class="table-responsive mb-4 mt-4">
<button type="button" data-target="#tambah" data-toggle="modal" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</button>
<table id="zero-config" class="table table-hover" style="width:100%">
<thead>
<tr>
<th>No</th>
<th>Kategori</th>
<th style="width: 15%">Aksi</th>
</tr>
</thead>
<tbody>
@php $no = 1; @endphp
@foreach ($bidangpenelitiankategori as $value)
<tr>
<td>{{ $no++ }}</td>
<td>{{ $value->namabidang }}</td>
<td>
<a href="{{ url('bidangpenelitian/'.$value->id.'/edit') }}" class="btn btn-warning mb-2"><i data-feather="edit"></i></a>
{{-- <button class="btn btn-danger mb-2 delete" data-id="{{ $value->id }}" data-file="{{$value->id}}"><i data-feather="trash-2"></i></button>
{{ Form::open(['url'=>route('admin.bidangpenelitian.destroy', [Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
{{ csrf_field() }}
{{ Form::close() }} --}}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="tambah" tabindex="-1" role="dialog" aria-labelledby="ModalTambah" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTambah">Tambah Kategori Bidang Penelitian</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
{{ Form::open(['url' => route('admin.bidangkategori.simpan'), 'method' => 'post', 'class' => 'section general-info', 'id' => 'bidangkategori']) }}
<div class="modal-body">
<div class="form-group">
<label>Nama Kategori Bidang Penelitian</label>
<input type="text" class="form-control mb-2" id="nama" name="nama" placeholder="Nama Kategori Bidang Penelitian">
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal"><i class="flaticon-cancel-12"></i> Batal</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
{{ Form::close() }}
</div>
</div>
</div>
@endsection
@section('js')
<script src="{{ url('theme/plugins/table/datatable/datatables.js') }}"></script>
<script>
$('#zero-config').DataTable({
"oLanguage": {
"oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
"sInfo": "Showing page _PAGE_ of _PAGES_",
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
"sSearchPlaceholder": "Search...",
"sLengthMenu": "Results : _MENU_",
},
"stripeClasses": [],
"lengthMenu": [10, 20, 50],
"pageLength": 10
});
var url = "{{ route('admin.bidangpenelitian.index') }}";
$("body").on("click", ".delete", function (e) {
e.preventDefault();
var id = $(this).data('id');
Swal.fire({
title: "Apakah Anda Yakin?",
text: "Anda akan menghapus data ini!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No"
}).then((result) => {
if (result.value) {
Swal.close();
$("#"+id).submit();
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire('Dibatalkan', 'Data batal dihapus', 'error');
}
});
});
</script>
@endsection
......@@ -43,9 +43,11 @@ Route::group(['middleware' => ['auth:sanctum', 'verified']], function () {
return view('dashboard');
})->name('dashboard');
Route::name('admin')->prefix('admin')->middleware(['role:admin'])->group(function () {
Route::name('admin.')->prefix('admin')->middleware(['role:admin'])->group(function () {
Route::resource('/bidangpenelitian', AdminBidangPenelitianController::class);
Route::get('/bidangkategori', [AdminBidangPenelitianController::class, 'bidangkategori'])->name('bidangkategori');
Route::get('/bidangkategoriedit/{id}', [AdminBidangPenelitianController::class, 'kategoriedit'])->name('bidangkategori.edit');
Route::post('/bidangkategori-simpan', [AdminBidangPenelitianController::class, 'kategoristore'])->name('bidangkategori.simpan');
Route::resource('/tujuansosial', AdminTujuanSosialController::class);
Route::get('/tujuankategori', [AdminTujuanSosialController::class, 'tujuankategori'])->name('tujuankategori');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment