Skip to content

Commit

Permalink
Latest Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiextreme committed Sep 13, 2022
1 parent 3fecd90 commit f973934
Show file tree
Hide file tree
Showing 68 changed files with 4,103 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function store(LoginRequest $request)
return redirect()->intended('/dashboard');
}else{
// if(Laratrust::hasRole('Pengguna')){
return redirect()->intended('/dashboard/pengguna');
return redirect()->intended('/dashboard');
// }
}
}
Expand Down
127 changes: 127 additions & 0 deletions app/Http/Controllers/Common/CommonController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

namespace App\Http\Controllers\Common;

use App\Http\Controllers\Controller;
use App\Models\Mykj\ListPegawai2;
use App\Models\Tetapan\Bangunan;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

class CommonController extends Controller
{
public static function errorResponse($message){
return response()->json($message)->setStatusCode(500)->header('Content-Type', 'application/json');
}

public static function dateAugment($date, $reverse = false){
return date($reverse ? 'd-m-Y' : 'Y-m-d', strtotime($date) );
}

public static function get_profile(){

$profile = Auth::user()->userProfile;

$data['first_name'] = $profile->first_name ?? null;
$data['last_name'] = $profile->last_name ?? null;
$data['ic_no'] = $profile->ic_no ?? null;
$data['genders_id'] = $profile->genders_id ?? null;
$data['dob'] = isset($profile->dob) ? self::dateAugment($profile->dob, true) : null;
$data['sob_id'] = $profile->sob_id ?? null;
$data['cob_id'] = $profile->cob_id ?? null;
$data['marital_statuses'] = $profile->marital_statuses_id ?? null;

return response()->json([
'success' => 1,
'data' => $data
]);
}

public static function upload_image($photo, $folder){
$filename = $photo->getClientOriginalName();
$extension = $photo->getClientOriginalExtension();
$image = str_replace(' ', '+', $photo);
$imagename = Str::random(10).'.'. $extension;
$photo->move($folder, $imagename);

return $imagename;
}

public static function unlink_image($folder){
File::delete($folder);
}

public static function getModel($class, $trigger, $id = false){

if($trigger == 0){
$model = new $class;
$model->flag = 1;
$model->delete_id = 0;
return $model;
}else{
return $class::find($id);
}
}

public static function softDeleteRecord($class, $id) : void{
$getModel = CommonController::getModel($class, 1, $id);
$getModel->delete_id = 1;
$getModel->save();
}

public static function activateRecord($class, $id) : void{
$getModel = CommonController::getModel($class, 1, $id);
$getModel->flag = $getModel->flag == 1 ? 0 : 1;
$getModel->save();
}

public function getBangunan(Request $request){
$model = Bangunan::where('lokasis_id', $request->input('lokasi_id'))->where('flag', 1)->where('delete_id', 0)->get();
$data = [];
if($model){
foreach($model as $m){
$data[] = [
'label' => $m->nama,
'value' => $m->id,
];
}
}

return response()->json([
'success' => 1,
'data' => $data
]);
}

public function pengguna_carian(Request $request){

$data = [];
$search_term = $request->input('q');
$peribadi = ListPegawai2::where('nokp', 'ilike', '%'.$search_term.'%')
->orWhereRaw("LOWER(nama) ilike '%".$search_term."%'")->limit(10)->get();

if(count($peribadi) != 0){
foreach($peribadi as $p){
$data[] = array(
'id' => $p->nokp,
'text' => html_entity_decode($p->nama, ENT_QUOTES | ENT_HTML5).' - '.$p->nokp
);
}
}

return response()->json([
'data' => $data
]);
}

public function pengguna_telefon(Request $request){
$model = ListPegawai2::getMaklumatPegawai($request->input('nokp'));

return response()->json([
'data' => str_replace('-', '', $model['tel_bimbit'])
]);

}
}
81 changes: 81 additions & 0 deletions app/Http/Controllers/Segment/Admin/Bilik/BilikController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
namespace App\Http\Controllers\Segment\Admin\Bilik;

use App\Http\Controllers\Common\CommonController;
use App\Http\Controllers\Controller;
use App\Models\Tetapan\Bangunan;
use App\Models\Tetapan\BangunanBilik;
use App\Models\Tetapan\Lokasi;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;

class BilikController extends Controller{
public function __construct()
{
$this->middleware('auth');
}

public function index(){
$lokasiList = Lokasi::where('flag', 1)->where('delete_id', 0)->get();
return view('segment.admin.bilik.index', [
'lokasiList' => $lokasiList
]);
}

public function getBilikList(){
$model = BangunanBilik::where('delete_id', 0);

return DataTables::of($model)
->setRowAttr([
'data-bilik-id' => function($data) {
return $data->id;
},
])
->addColumn('nama', function($data){
return $data->nama;
})->addColumn('lokasi_bangunan_aras', function($data){
return $data->bilikBangunan->nama.' / Aras '.$data->aras.' / Bangunan '.$data->bilikBangunan->bangunanLokasi->nama;
})
->addColumn('action', function($data){
})
->rawColumns(['action'])
->make(true);
}

public function bilikStoreUpdate(Request $request){
return BangunanBilik::storeUpdate($request);
}

public function getBilik(Request $request){
$id = $request->input('id');
$model = BangunanBilik::find($id);

$data = [];
$data['nama'] = $model->nama;
$data['lokasi_id'] = $model->bilikBangunan->lokasis_id;
$data['bangunan_id'] = $model->bangunans_id;
$data['aras'] = $model->aras;
$data['kapasiti'] = $model->kapasiti;

return response()->json([
'success' => 1,
'data' => $data
]);
}

public function activateBilik(Request $request){
CommonController::activateRecord(BangunanBilik::class, $request->input('id'));

return response()->json([
'success' => 1,
'data' => [],
]);
}

public function deleteBilik(Request $request){
CommonController::softDeleteRecord(BangunanBilik::class, $request->input('id'));
return response()->json([
'success' => 1,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers\Segment\Admin\Tetapan\Bangunan;

use App\Http\Controllers\Common\CommonController;
use App\Http\Controllers\Controller;
use App\Models\Tetapan\Bangunan;
use App\Models\Tetapan\Lokasi;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;

class TetapanBangunanController extends Controller{
public function __construct()
{
$this->middleware('auth');
}

public function index(){
$lokasiList = Lokasi::where('delete_id', 0)->where('flag', 1)->get();
return view('segment.admin.tetapan.bangunan.index', [
'lokasiList' => $lokasiList
]);
}

public function getBangunanList(){
$model = Bangunan::where('delete_id', 0);

return DataTables::of($model)
->setRowAttr([
'data-bangunan-id' => function($data) {
return $data->id;
},
])
->addColumn('nama', function($data){
return $data->nama;
})->addColumn('lokasi', function($data){
return $data->bangunanLokasi->nama;
})
->addColumn('action', function($data){
})
->rawColumns(['action'])
->make(true);
}

public function bangunanStoreUpdate(Request $request){
return Bangunan::storeUpdate($request);
}

public function getBangunan(Request $request){
$id = $request->input('id');
$model = Bangunan::find($id);

$data = [];
$data['nama'] = $model->nama;
$data['lokasi_id'] = $model->lokasis_id;

return response()->json([
'success' => 1,
'data' => $data
]);
}

public function activateBangunan(Request $request){
CommonController::activateRecord(Bangunan::class, $request->input('id'));

return response()->json([
'success' => 1,
'data' => [],
]);
}

public function deleteBangunan(Request $request){
CommonController::softDeleteRecord(Bangunan::class, $request->input('id'));
return response()->json([
'success' => 1,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
namespace App\Http\Controllers\Segment\Admin\Tetapan\Fasiliti;

use App\Http\Controllers\Common\CommonController;
use App\Http\Controllers\Controller;
use App\Models\Tetapan\Fasiliti;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;

class TetapanFasilitiController extends Controller{
public function __construct()
{
$this->middleware('auth');
}

public function index(){
return view('segment.admin.tetapan.fasiliti.index');
}

public function getFasilitiList(){
$model = Fasiliti::where('delete_id', 0);

return DataTables::of($model)
->setRowAttr([
'data-fasiliti-id' => function($data) {
return $data->id;
},
])
->addColumn('nama', function($data){
return $data->nama;
})
->addColumn('action', function($data){
})
->rawColumns(['action'])
->make(true);
}

public function fasilitiStoreUpdate(Request $request){
return Fasiliti::storeUpdate($request);
}

public function getFasiliti(Request $request){
$id = $request->input('id');
$model = Fasiliti::find($id);

$data = [];
$data['nama'] = $model->nama;

return response()->json([
'success' => 1,
'data' => $data
]);
}

public function activateFasiliti(Request $request){
CommonController::activateRecord(Fasiliti::class, $request->input('id'));

return response()->json([
'success' => 1,
'data' => [],
]);
}

public function deleteFasiliti(Request $request){
CommonController::softDeleteRecord(Fasiliti::class, $request->input('id'));
return response()->json([
'success' => 1,
]);
}
}
Loading

0 comments on commit f973934

Please sign in to comment.